Skip to content

Commit 8f2b7e7

Browse files
committed
chore: rollup config
Inject Craft package version and export sourcemaps
1 parent b0a9e0b commit 8f2b7e7

File tree

9 files changed

+41
-3
lines changed

9 files changed

+41
-3
lines changed

.changeset/fast-tigers-jump.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@craftjs/core': patch
3+
'@craftjs/layers': patch
4+
'@craftjs/utils': patch
5+
---
6+
7+
Inject Craft package version and export sourcemaps

packages/core/.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
src
22
rollup.config.js
33
tsconfig.json
4-
nodemon.json
4+
nodemon.json
5+
.rollup.cache

packages/core/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"main": "./dist/cjs/index.js",
2222
"module": "./dist/esm/index.js",
2323
"types": "./lib/index.d.ts",
24+
"files": [
25+
"dist"
26+
],
2427
"repository": {
2528
"type": "git",
2629
"url": "https://github.com/prevwong/craft.js/"

packages/layers/.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
src
22
rollup.config.js
3-
tsconfig.json
3+
tsconfig.json
4+
.rollup.cache

packages/layers/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"module": "./dist/esm/index.js",
1818
"license": "MIT",
1919
"types": "./lib/index.d.ts",
20+
"files": [
21+
"dist"
22+
],
2023
"scripts": {
2124
"start": "cross-env NODE_ENV=development ../../scripts/build.sh",
2225
"build": "cross-env NODE_ENV=production ../../scripts/build.sh",

packages/utils/.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
src
22
rollup.config.js
33
tsconfig.json
4-
nodemon.json
4+
nodemon.json
5+
.rollup.cache

packages/utils/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"main": "./dist/cjs/index.js",
88
"module": "./dist/esm/index.js",
99
"types": "./lib/index.d.ts",
10+
"files": [
11+
"dist"
12+
],
1013
"scripts": {
1114
"start": "cross-env NODE_ENV=development ../../scripts/build.sh",
1215
"build": "cross-env NODE_ENV=production ../../scripts/build.sh",

rollup.config.js

+18
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,38 @@ import typescript from '@rollup/plugin-typescript';
88
const shouldMinify = process.env.NODE_ENV === 'production';
99
const bundle = ['tslib'];
1010

11+
const injectPackageVersion = () => {
12+
const pkg = require('./package.json');
13+
14+
return `
15+
if ( typeof window !== 'undefined' ) {
16+
if ( !window['__CRAFTJS__'] ) {
17+
window['__CRAFTJS__'] = {};
18+
}
19+
20+
window['__CRAFTJS__']["${pkg.name}"] = "${pkg.version}";
21+
}
22+
`;
23+
};
24+
1125
export default {
1226
input: './src/index.ts',
1327
output: [
1428
{
1529
file: 'dist/esm/index.js',
1630
format: 'esm',
31+
intro: injectPackageVersion(),
1732
globals: {
1833
react: 'React',
1934
'react-dom': 'ReactDOM',
2035
},
36+
sourcemap: true,
2137
},
2238
{
2339
file: 'dist/cjs/index.js',
40+
intro: injectPackageVersion(),
2441
format: 'cjs',
42+
sourcemap: true,
2543
},
2644
],
2745
external: (id) => {

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"allowSyntheticDefaultImports": true,
66
"allowJs": true,
77
"esModuleInterop": true,
8+
"sourceMap": true,
89
"paths": {
910
"@craftjs/core": ["packages/core/src/index"],
1011
"@craftjs/*": ["packages/core/src/*"],

0 commit comments

Comments
 (0)