Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move to rollup for better umd bundles
add bundled outputs for commonjs and esm remove unnecessary config rules from module bundles single output since it doesnt need to be dynamic
- Loading branch information
Adam Markon
committed
Mar 23, 2019
1 parent
f8c96ee
commit 958c899
Showing
7 changed files
with
338 additions
and
1,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import typescript from 'rollup-plugin-typescript'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import replace from 'rollup-plugin-replace'; | ||
import { uglify } from 'rollup-plugin-uglify'; | ||
|
||
const bundle = env => { | ||
const file = | ||
env === 'production' | ||
? 'dist/general-store.min.js' | ||
: 'dist/general-store.js'; | ||
const additionalPlugins = []; | ||
if (env === 'production') { | ||
additionalPlugins.push(uglify()); | ||
} | ||
const config = { | ||
input: './src/GeneralStore.ts', | ||
plugins: [ | ||
typescript(), | ||
commonjs(), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify(env), | ||
}), | ||
resolve({ | ||
browser: true, | ||
}), | ||
...additionalPlugins, | ||
], | ||
output: [ | ||
{ | ||
file, | ||
format: 'umd', | ||
exports: 'named', | ||
compact: env === 'production', | ||
globals: { | ||
react: 'React', | ||
}, | ||
}, | ||
], | ||
external: ['react'], | ||
}; | ||
return config; | ||
}; | ||
const moduleBundleConfig = { | ||
input: './src/GeneralStore.ts', | ||
plugins: [ | ||
typescript(), | ||
commonjs(), | ||
resolve({ | ||
browser: true, | ||
}), | ||
], | ||
output: [ | ||
{ | ||
file: `dist/general-store.cjs.js`, | ||
format: 'cjs', | ||
}, | ||
{ | ||
file: `dist/general-store.esm.js`, | ||
format: 'esm', | ||
}, | ||
], | ||
external: ['react'], | ||
}; | ||
|
||
export default [ | ||
bundle('development'), | ||
bundle('production'), | ||
moduleBundleConfig, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"esModuleInterop": true, | ||
"module": "commonjs", | ||
"jsx": "react" | ||
}, | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.