You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
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 PR is a final step in Babel migration and aims to improve and simplify our bundling, too.
New distribution structure
Each package will have the following structure:
dist-node - single bundled file with CommonJS modules distribution
dist-src - source files compiled with Babel, has the same structure as project, preserves ability to pick single files from project
dist-types - contains bundle single file with types (expect @stardust-ui/react, see below why)
dist-web - an ESM distribution of package via single file, built & optimized to run in most web browsers, tree shaking will work properly in this case, don't worry 馃摝
Single file distribution becomes standard, even React is distributed via single file. Current distribution for ES modules includes 1,556 files, it's definitely better to have one for bundlers 鉂わ笍
Uses @pika/pack
To get the structure above no custom code is required, everything is done using @pika/pack, this allow us to add custom stages to their pipeline and make complicated bundling easily 馃憤
Configured @babel/preset-env
We use .browserslistrc to target required browsers, this setting can be adjusted later, current config.
Adds @pika/plugin-build-types
It's a custom plugin that will bundle definitions to a single file with rollup-plugin-dts, the nicest thing is that it will contain only publicly exported definitions 馃惡
Switch to @babel/runtime
As we switched to Babel, we also replaced tslib with @babel/runtime-corejs2.
babel-plugin-lodash
This PR also introduces the first babel plugin that aims to optimize bundle size. Lodash is CJS and can't be treeshaked, it means that import _ from 'lodash' will include the whole library (70 Kb) 馃槶
This plugin will transform import _ from 'lodash' to import _map from 'lodash/map' where _map is module required in your file.
TS Project References for @stardust-ui/react
There is only one reason to introduce this: our withSafeTypeForAs() creates very complicated TS definitions and these definitions can't be bundled due some bugs in rollup-plugin-dts 馃挘
Because of this, the PR also introduces changes to our tsconfig.json's to use Project References feature. It was designed also to handle monorepo cases (microsoft/TypeScript#25376).
When you reference a project, new things happen:
Importing modules from a referenced project will instead load its output declaration file (.d.ts)
If the referenced project produces an outFile, the output file .d.ts file鈥檚 declarations will be visible in this project
layershifter
changed the title
feat(Ref): extract to a separate package, update bundling
[WIP] feat(Ref): extract to a separate package, update bundling
Apr 9, 2019
layershifter
changed the title
[WIP] feat(Ref): extract to a separate package, update bundling
[WIP] chore(package): use pikapkg to bundle packages
May 5, 2019
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #508.
Improve bundling :yay
This PR is a final step in Babel migration and aims to improve and simplify our bundling, too.
New distribution structure
Each package will have the following structure:
dist-node
- single bundled file with CommonJS modules distributiondist-src
- source files compiled with Babel, has the same structure as project, preserves ability to pick single files from projectdist-types
- contains bundle single file with types (expect@stardust-ui/react
, see below why)dist-web
- an ESM distribution of package via single file, built & optimized to run in most web browsers, tree shaking will work properly in this case, don't worry 馃摝Single file distribution becomes standard, even React is distributed via single file. Current distribution for ES modules includes 1,556 files, it's definitely better to have one for bundlers 鉂わ笍
Uses
@pika/pack
To get the structure above no custom code is required, everything is done using
@pika/pack
, this allow us to add custom stages to their pipeline and make complicated bundling easily 馃憤Configured
@babel/preset-env
We use
.browserslistrc
to target required browsers, this setting can be adjusted later, current config.Adds
@pika/plugin-build-types
It's a custom plugin that will bundle definitions to a single file with
rollup-plugin-dts
, the nicest thing is that it will contain only publicly exported definitions 馃惡Switch to
@babel/runtime
As we switched to Babel, we also replaced
tslib
with@babel/runtime-corejs2
.babel-plugin-lodash
This PR also introduces the first babel plugin that aims to optimize bundle size. Lodash is CJS and can't be treeshaked, it means that
import _ from 'lodash'
will include the whole library (70 Kb) 馃槶This plugin will transform
import _ from 'lodash'
toimport _map from 'lodash/map'
where_map
is module required in your file.TS Project References for
@stardust-ui/react
There is only one reason to introduce this: our
withSafeTypeForAs()
creates very complicated TS definitions and these definitions can't be bundled due some bugs inrollup-plugin-dts
馃挘https://cdn.jsdelivr.net/npm/@stardust-ui/react@0.30.0/dist/es/components/Chat/Chat.d.ts
https://cdn.jsdelivr.net/npm/@stardust-ui/react@0.31.0/dist/es/components/Chat/Chat.d.ts
Because of this, the PR also introduces changes to our
tsconfig.json
's to use Project References feature. It was designed also to handle monorepo cases (microsoft/TypeScript#25376).https://www.typescriptlang.org/docs/handbook/project-references.html
This feature allows to properly define
rootDir
option intsconfig.json
and generate output proper typings by compiler:Without the references feature it will fail because TypeScript doesn't know anything about modules structure:
Ongoing stuff
babel-transform-remove-proptypes