Skip to content

Commit

Permalink
chore: rollup config
Browse files Browse the repository at this point in the history
Inject Craft package version and export sourcemaps
  • Loading branch information
prevwong committed Jul 26, 2024
1 parent b0a9e0b commit 8f2b7e7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/fast-tigers-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@craftjs/core': patch
'@craftjs/layers': patch
'@craftjs/utils': patch
---

Inject Craft package version and export sourcemaps
3 changes: 2 additions & 1 deletion packages/core/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src
rollup.config.js
tsconfig.json
nodemon.json
nodemon.json
.rollup.cache
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./lib/index.d.ts",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/prevwong/craft.js/"
Expand Down
3 changes: 2 additions & 1 deletion packages/layers/.npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
src
rollup.config.js
tsconfig.json
tsconfig.json
.rollup.cache
3 changes: 3 additions & 0 deletions packages/layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
"module": "./dist/esm/index.js",
"license": "MIT",
"types": "./lib/index.d.ts",
"files": [
"dist"
],
"scripts": {
"start": "cross-env NODE_ENV=development ../../scripts/build.sh",
"build": "cross-env NODE_ENV=production ../../scripts/build.sh",
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src
rollup.config.js
tsconfig.json
nodemon.json
nodemon.json
.rollup.cache
3 changes: 3 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./lib/index.d.ts",
"files": [
"dist"
],
"scripts": {
"start": "cross-env NODE_ENV=development ../../scripts/build.sh",
"build": "cross-env NODE_ENV=production ../../scripts/build.sh",
Expand Down
18 changes: 18 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@ import typescript from '@rollup/plugin-typescript';
const shouldMinify = process.env.NODE_ENV === 'production';
const bundle = ['tslib'];

const injectPackageVersion = () => {
const pkg = require('./package.json');

return `
if ( typeof window !== 'undefined' ) {
if ( !window['__CRAFTJS__'] ) {
window['__CRAFTJS__'] = {};
}
window['__CRAFTJS__']["${pkg.name}"] = "${pkg.version}";
}
`;
};

export default {
input: './src/index.ts',
output: [
{
file: 'dist/esm/index.js',
format: 'esm',
intro: injectPackageVersion(),
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
sourcemap: true,
},
{
file: 'dist/cjs/index.js',
intro: injectPackageVersion(),
format: 'cjs',
sourcemap: true,
},
],
external: (id) => {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"allowSyntheticDefaultImports": true,
"allowJs": true,
"esModuleInterop": true,
"sourceMap": true,
"paths": {
"@craftjs/core": ["packages/core/src/index"],
"@craftjs/*": ["packages/core/src/*"],
Expand Down

0 comments on commit 8f2b7e7

Please sign in to comment.