Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(esm): fix tree shaking on ESM build (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick Croissant authored Sep 25, 2020
1 parent 986a992 commit 5261883
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 49 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist/
es/
yarn-error.log
node_modules/
coverage
Expand Down
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
"version": "3.2.0",
"files": [
"dist",
"src"
"src",
"es"
],
"main": "dist/vue-instantsearch.common.js",
"module": "dist/vue-instantsearch.esm.js",
"module": "es/src/instantsearch.js",
"sideEffects": false,
"repository": "https://github.com/algolia/vue-instantsearch",
"scripts": {
"build": "rollup -c",
"build": "rm -rf dist es && rollup -c",
"storybook": "start-storybook -p 9001 -c .storybook",
"storybook:build": "build-storybook -c .storybook -o website/stories",
"examples:build": "yarn build && ./examples/build.sh",
Expand Down Expand Up @@ -87,7 +88,7 @@
"jest-watch-typeahead": "0.2.1",
"lodash": "4.17.19",
"prettier": "1.14.3",
"rollup": "1.16.7",
"rollup": "1.32.1",
"rollup-plugin-buble": "0.19.6",
"rollup-plugin-commonjs": "10.0.1",
"rollup-plugin-filesize": "9.0.0",
Expand Down Expand Up @@ -115,10 +116,6 @@
"path": "./dist/vue-instantsearch.js",
"maxSize": "48.00 kB"
},
{
"path": "./dist/vue-instantsearch.esm.js",
"maxSize": "15.75 kB"
},
{
"path": "./dist/vue-instantsearch.common.js",
"maxSize": "16 kB"
Expand Down
60 changes: 32 additions & 28 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ const processEnv = conf => ({
'process.env': `(${JSON.stringify(conf)})`,
});

const plugins = [
commonjs(),
vue({ compileTemplate: true, css: false }),
json(),
buble({
transforms: {
dangerousForOf: true,
},
}),
replace(processEnv({ NODE_ENV: 'production' })),
terser({
sourcemap: true,
}),
filesize(),
];

export default [
{
input: 'src/instantsearch.js',
Expand All @@ -28,26 +44,26 @@ export default [
format: 'cjs',
exports: 'named',
},
],
plugins: [...plugins],
},
{
input: 'src/instantsearch.js',
external: [
'algoliasearch-helper',
'instantsearch.js/es',
'instantsearch.js/es/connectors',
'vue',
],
output: [
{
sourcemap: true,
file: `dist/vue-instantsearch.esm.js`,
dir: `es`,
format: 'es',
},
],
plugins: [
commonjs(),
vue({ compileTemplate: true, css: false }),
json(),
buble({
transforms: {
dangerousForOf: true,
},
}),
terser({
sourcemap: true,
}),
filesize(),
],
preserveModules: true,
plugins: [...plugins],
},
{
input: 'src/instantsearch.umd.js',
Expand All @@ -65,23 +81,11 @@ export default [
},
],
plugins: [
vue({ compileTemplate: true, css: false }),
json(),
...plugins,
resolve({
browser: true,
preferBuiltins: false,
}),
buble({
transforms: {
dangerousForOf: true,
},
}),
replace(processEnv({ NODE_ENV: 'production' })),
commonjs(),
terser({
sourcemap: true,
}),
filesize(),
],
},
];
31 changes: 18 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==

"@types/estree@*":
version "0.0.45"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.45.tgz#e9387572998e5ecdac221950dab3e8c3b16af884"
integrity sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==

"@types/[email protected]":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
Expand Down Expand Up @@ -730,11 +735,6 @@
resolved "https://registry.npmjs.org/@types/node/-/node-14.0.13.tgz#ee1128e881b874c371374c1f72201893616417c9"
integrity sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==

"@types/node@^12.0.10":
version "12.6.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.3.tgz#44d507c5634f85e7164707ca36bba21b5213d487"
integrity sha512-7TEYTQT1/6PP53NftXXabIZDaZfaoBdeBm8Md/i7zsWRoBe0YwOXguyK8vhHs8ehgB/w9U4K/6EWuTyp0W6nIA==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
Expand Down Expand Up @@ -1025,11 +1025,16 @@ acorn@^5.5.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.3.tgz#67aa231bf8812974b85235a96771eb6bd07ea279"
integrity sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==

acorn@^6.0.7, acorn@^6.1.1:
acorn@^6.0.7:
version "6.1.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f"
integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==

acorn@^7.1.0:
version "7.4.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.0.tgz#e1ad486e6c54501634c6c397c5c121daa383607c"
integrity sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==

add-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa"
Expand Down Expand Up @@ -13355,14 +13360,14 @@ [email protected]:
require-relative "0.8.7"
rollup-pluginutils "^2.0.1"

rollup@1.16.7:
version "1.16.7"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.16.7.tgz#4b539ca22465df39f6c963d2001d95f6527e97e1"
integrity sha512-P3GVcbVSLLjHWFLKGerYRe3Q/yggRXmTZFx/4WZf4wzGwO6hAg5jyMAFMQKc0dts8rFID4BQngfoz6yQbI7iMQ==
rollup@1.32.1:
version "1.32.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.32.1.tgz#4480e52d9d9e2ae4b46ba0d9ddeaf3163940f9c4"
integrity sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==
dependencies:
"@types/estree" "0.0.39"
"@types/node" "^12.0.10"
acorn "^6.1.1"
"@types/estree" "*"
"@types/node" "*"
acorn "^7.1.0"

rsvp@^3.3.3:
version "3.6.2"
Expand Down

0 comments on commit 5261883

Please sign in to comment.