add .js extension in the import statement #16276
Merged
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.
Brief Information
This pull request is in the type of:
What does this PR do?
As discussed in #16054. This PR trys to add an extra transform step to add
.js
extension to the import statement afterlib
is generated.So before the statement is:
Now it becomes:
So specific modules in the
lib
can be imported in the browsers more conveniently.Misc
Related test cases or examples to use the new APIs
Still there some required steps needs to be done before we actually importing the modules:
process.env.NODE_ENV
on the dev only code. We need to define it in the browsers environmentThen we can importing modules just like in the bundling environment.
But still there are limitations. Because this API design heavliy depends on dead code removal to do the tree-shaking, which seems to be not supported by the browsers yet. So it will still import all the charts from
echarts/charts.js
, not only the pie chart we needed.This problem not exists if we use our legacy partially importing API:
It will only import the pie chart and all the modules it depends on.
Others
Merging options
Other information