File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+
4+ // This file will only export default exports in commonjs bundles
5+ // instead of guarding them behind a `.default` property.
6+
7+ const filePath = ( file ) => path . join ( process . cwd ( ) , 'dist' , file ) ;
8+
9+ // Main entry
10+ fs . copyFileSync ( filePath ( 'index.js' ) , filePath ( 'commonjs.js' ) ) ;
11+ fs . copyFileSync ( filePath ( 'index.js.map' ) , filePath ( 'commonjs.js.map' ) ) ;
12+
13+ const source = `module.exports = require('./commonjs').default;` ;
14+ fs . writeFileSync ( filePath ( 'index.js' ) , source , 'utf-8' ) ;
15+
16+ // JSX entry
17+ fs . copyFileSync ( filePath ( 'jsx.js' ) , filePath ( 'jsx-entry.js' ) ) ;
18+ fs . copyFileSync ( filePath ( 'jsx.js.map' ) , filePath ( 'jsx-entry.js.map' ) ) ;
19+
20+ const sourceJsx = `module.exports = require('./jsx-entry').default;` ;
21+ fs . writeFileSync ( filePath ( 'jsx.js' ) , sourceJsx , 'utf-8' ) ;
Original file line number Diff line number Diff line change 2323 },
2424 "scripts" : {
2525 "build" : " npm run -s transpile && npm run -s transpile:jsx && npm run -s copy-typescript-definition" ,
26- "postbuild" : " node ./config/node-13-exports.js" ,
26+ "postbuild" : " node ./config/node-13-exports.js && node ./config/node-commonjs.js " ,
2727 "transpile" : " microbundle src/index.js -f es,umd --target web --external preact" ,
2828 "transpile:jsx" : " microbundle src/jsx.js -o dist/jsx.js --target web --external none && microbundle dist/jsx.js -o dist/jsx.js -f cjs" ,
2929 "copy-typescript-definition" : " copyfiles -f src/*.d.ts dist" ,
You can’t perform that action at this time.
0 commit comments