-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Switches from Webpack/TSC to Rollup. This change exports ESM and CJS in addition to the standard UMD.
- Loading branch information
Showing
7 changed files
with
271 additions
and
32 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
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
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,45 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve' | ||
import typescript from '@rollup/plugin-typescript' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import { terser } from 'rollup-plugin-terser' | ||
|
||
const plugins = [ | ||
// TODO: this commonjs plugin will no longer be needed after file-saver is removed | ||
// once commonjs plugin is removed, this file can also be renamed to rollup.config.ts | ||
commonjs({ | ||
namedExports: { | ||
'file-saver': ['saveAs'] | ||
} | ||
}), | ||
typescript(), | ||
nodeResolve() | ||
] | ||
|
||
const getOutput = (format, config) => ({ | ||
format, | ||
sourcemap: true, | ||
exports: 'named', | ||
file: `dist/datebook.${format}.min.js`, | ||
...config | ||
}) | ||
|
||
export default [ | ||
{ | ||
// UMD | ||
input: 'src/index.ts', | ||
plugins: plugins.concat(terser()), | ||
output: getOutput('umd', { | ||
name: 'datebook', // this is the name of the global object | ||
esModule: false | ||
}) | ||
}, | ||
{ | ||
// ESM and CJS | ||
input: 'src/index.ts', | ||
plugins, | ||
output: [ | ||
getOutput('esm'), | ||
getOutput('cjs') | ||
] | ||
} | ||
] |
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
Oops, something went wrong.