This repository has been archived by the owner on Jun 25, 2020. It is now read-only.
fix: remove unnecessary css and remove esm from package.json #55
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.
🐛 Bug Fix
related to apache/superset#7058
Demo
Before
https://superset-ui-plugins.netlify.com
After
https://deploy-preview-55--superset-ui-plugins.netlify.com
Explanation
The way the packages are transpiled now produces two types of output:
lib
directory.esm
directory.In
package.json
main
point to the main entry of the library, which islib/index.js
module
point to the main entry point of the library that is es6 module, which isesm/index.js
. This is useful for bundler that are es6 module aware such aswebpack
>= 2, so it will use the code inesm
instead oflib
which it can do treeshaking, etc. better.However, for legacy modules that import
css
intojs
file, this creates problems when bundling for production.lib
after transpiled will berequire('xxx.css')
which works correctly withwebpack
production bundling.esm
after transpiled will beimport 'xxx.css'
which makes the css file not being pulled into production bundle and results in missing css, such as black screen, weird fonts, as reported in the issue above.Solution
In the longer term, we may need to get rid of the
js
code that importscss
in the library. Either by converting tocss
injs
or create singlecss
file that consumer of these packages have toimport
by themselves alongside thejs
, similar to howbootstrap
hasjs
andcss
.For the short term solution, this PR,
css
files that can be converted to justjs
.module
field frompackage.json
of the packages that hasimport 'xxx.css'
statements, so the consumer app/package will be usinglib/index.js
instead ofesm/index.js
whenwebpack
resolves the packages. This changes should require the smallest changes from the consumer app. Only bumping the version number.