-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bundle): update bundle strategy (#3260)
## Migrate from Webpack to Rollup Rollup is now used to bundle InstantSearch.js. Rollup is more suited for libraries. It allows us to create lighter bundles and multiple bundle strategies. | | Webpack | Rollup |---|---|--- | Bundle | 372 kB | 301 kB | GZipped | 97 kB | 84 kB This sizes are without any further optimizations (will come gradually). ## Different bundles This is what is exported: ``` dist ├── instantsearch.development.js ├── instantsearch.development.js.map ├── instantsearch.production.min.js └── instantsearch.production.min.js.map cjs ├── components ├── connectors ├── helpers ├── index.js ├── lib ├── src └── widgets es ├── components ├── connectors ├── helpers ├── index.js ├── lib └── widgets ``` ### UMD The files have been renamed to become clearer for the users. #### Usage ```html <script src="instantsearch.production.min.js"></script> ``` ### CJS #### Usage ```js const instantsearch = require('instantsearch.js').default ``` ### ES No changes. ## Development and production bundles Since the bundle is getting heavy, the migration to Rollup has made it easier to create separate UMD bundles: - `instantsearch.development.js` - `instantsearch.production.min.js` These names were inspired by the [React strategy](https://unpkg.com/[email protected]/umd/). The development bundle will include everything that the default bundle has so far. The production bundle will not include the warnings (everything that is runtime) and the verbose widget/connector usages. Everything under this condition will get stripped in the production bundle: ```js if (__DEV__) { // development only } ``` In the CJS and ES bundle, it's converted to: ```js if (process.env.NODE_ENV === 'development') { // development only } ``` ## What's next This new bundle strategy allows to gradually remove development feature from the production bundle.
- Loading branch information
1 parent
a5ff6af
commit a7dab81
Showing
53 changed files
with
664 additions
and
298 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
dist/ | ||
dist-es5-module/ | ||
/dist | ||
/cjs | ||
/es | ||
/docgen | ||
docs/ | ||
docs.old/ | ||
docgen/ | ||
node_modules/ | ||
es/ |
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,8 +1,11 @@ | ||
module.exports = { | ||
extends: ['algolia', 'algolia/jest', 'algolia/react'], | ||
rules: { | ||
"no-param-reassign": 0, | ||
"import/no-extraneous-dependencies": 0, | ||
"react/no-string-refs": 1 | ||
} | ||
} | ||
'no-param-reassign': 0, | ||
'import/no-extraneous-dependencies': 0, | ||
'react/no-string-refs': 1, | ||
}, | ||
globals: { | ||
__DEV__: false, | ||
}, | ||
}; |
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,18 +1,17 @@ | ||
node_modules/ | ||
dist/ | ||
dist-es5-module/ | ||
!scripts/docs/ | ||
npm-debug.log | ||
yarn-error.log | ||
.DS_Store | ||
docs/ | ||
!scripts/docs/ | ||
|
||
# Ignore staging build files | ||
dev/dist/* | ||
# Bundle build files | ||
/dist | ||
/cjs | ||
/es | ||
|
||
# Ignore Argos CI screenshots. | ||
functional-tests/screenshots/ | ||
# Generated files | ||
/docs | ||
/storybook/dist/* | ||
|
||
# Ignore ES6 build files | ||
es/ | ||
|
||
yarn-error.log | ||
# Argos CI screenshots | ||
/functional-tests/screenshots/ |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.