Skip to content

Commit

Permalink
fix: esm module import
Browse files Browse the repository at this point in the history
  • Loading branch information
manelet committed Nov 5, 2020
1 parent 4b4d17d commit 64786e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.0-development",
"description": "⚙️ String manipulation library",
"main": "dist/index.js",
"module": "dist/index.mjs",
"browser": "dist/str.js",
"module": "dist/index_es.mjs",
"browser": "dist/index_umd.js",
"types": "types/index.d.ts",
"scripts": {
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' nyc --reporter=lcov mocha './src/**/*.spec.ts' -r ts-node/register",
Expand Down
8 changes: 7 additions & 1 deletion rollup.browser.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
input: './src/index.ts',
output: [
{
file: pkg.browser,
file: './dist/str.js',
format: 'iife',
name: 'str',
sourcemap: true
Expand All @@ -18,6 +18,12 @@ export default {
name: 'str',
plugins: [terser()],
sourcemap: true
},
{
file: pkg.browser,
format: 'umd',
name: 'str',
plugins: [terser()],
}
],
external: [...Object.keys(pkg.dependencies || {})],
Expand Down
10 changes: 2 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ export default {
},
{
dir: './dist',
entryFileNames: '[name].mjs',
entryFileNames: '[name]_es.mjs',
format: 'es',
sourcemap: false
// esModule: false
},
// {
// file: pkg.browser,
// format: 'iife',
// name: 'str'
// }
],
external: [...Object.keys(pkg.dependencies || {})],
plugins: [
Expand All @@ -52,7 +46,7 @@ export default {
transform: (contents) => {
const p = JSON.parse(contents.toString('utf8'))
p.main = p.main.replace('dist/', '')
p.module = p.module.replace('dist/', '')
// p.module = p.module.replace('dist/', '')
p.browser = p.browser.replace('dist/', '')
return JSON.stringify(p, null, 2)
}
Expand Down

0 comments on commit 64786e8

Please sign in to comment.