airbnb / babel-plugin-dynamic-import-webpack Goto Github PK
View Code? Open in Web Editor NEWBabel plugin to transpile import() to require.ensure, for Webpack
License: MIT License
Babel plugin to transpile import() to require.ensure, for Webpack
License: MIT License
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Can I use it in React Native?
Branch | Build failing 🚨 |
---|---|
Dependency | eslint |
Current Version | 4.10.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
lines-around-comment
(#9589) (Clément Fiorio)npm test
(#9590) (Teddy Katz)no-invalid-this
. (#9542) (Francisc)The new version differs by 35 commits.
1a9a6a5
4.11.0
ef4d268
Build: changelog update for 4.11.0
d4557a6
Docs: disallow use of the comma operator using no-restricted-syntax (#9585)
d602f9e
Upgrade: espree v3.5.2 (#9611)
4def876
Chore: avoid handling rules instances in config-validator (#9364)
fe5ac7e
Chore: fix incorrect comment in safe-emitter.js (#9605)
6672fae
Docs: Fixed a typo on lines-between-class-members doc (#9603)
980ecd3
Chore: Update copyright and license info (#9599)
cc2c7c9
Build: use Node 8 in appveyor (#9595)
2542f04
Docs: Add missing options for lines-around-comment
(#9589)
b6a7490
Build: ensure fuzzer tests get run with npm test
(#9590)
1073bc5
Build: remove shelljs-nodecli (refs #9533) (#9588)
7e3bf6a
Fix: edge-cases of semi-style (#9560)
e5a37ce
Fix: object-curly-newline for flow code (#9458)
9064b9c
Chore: add equalTokens in ast-utils. (#9500)
There are 35 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | babel-cli |
Current Version | 6.22.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As babel-cli is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | safe-publish-latest |
Current Version | 1.1.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
safe-publish-latest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 26 commits.
a88a710
v1.1.2
d82e47a
[Tests] up to node
v10.8
, v9.11
, v8.11
, v6.14
, v4.9
; use nvm install-latest-npm
8c5878d
[Dev Deps] update eslint
, @ljharb/eslint-config
, nsp
, tape
632c8a9
[Tests] up to node
v9.4
, v8.9
, v6.12
; use nvm install-latest-npm
; pin included builds to LTS
71972c6
[Deps] update semver
64dbc28
[Dev Deps] update eslint
, nsp
3abce66
[Deps] update semver
7249655
[Dev Deps] update eslint
, @ljharb/eslint-config
, nsp
, tape
5fe7d29
[Dev Deps] update eslint
, @ljharb/eslint-config
, tape
8cc40c7
[Tests] add editorconfig-tools
739e547
[Tests] up to node
v8
, v7.10
; npm v5+ fails on node < v4
55fa31f
Only apps should have lockfiles.
040194f
[Tests] require 0.8 to be passing again
dfddb24
[Deps] pin yargs to v7, since v8 drops node < 4 compat.
376c98d
[Tests] allow 0.8 to fail, pending burl/mock-env#2
There are 26 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
not work in webpack3
I have the following Babel config:
{
"presets": [
"react-app"
],
"plugins": [
"dynamic-import-webpack",
"transform-decorators-legacy"
]
}
I am also using Webpack 2.
In order to make everything work with this setup I have to do some custom stuff in React Router configuration:
<Route path='/' getComponent={() => import('../path/to/component').then(cmp => cmp.default)}/>
Without .then(cmp => cmp.default)
it does not work.
Hi there!
Cool stuff :)
I just have a small suggestion: A few short lines of sample code would be nice. You show how to use it, but not the code it's supposed to run on.
Or a link to the import()
spec. I was puzzled for a moment, since in my head import
is a keyword for static module imports and not a function :)
Updating from "^1.0.1" to "^1.0.2" has broken my code splitting. This shouldn't be a breaking change from a patch update.
{
test: /\.jsx?$/,
include: [ APP, CONFIG, SERVER ],
loader: 'babel-loader',
options: {
presets: [
[ 'env', {
targets: { browsers: [ 'last 2 versions' ] },
modules: false,
} ],
'react',
],
plugins: [
'dynamic-import-webpack',
'transform-export-extensions',
'transform-decorators-legacy',
'transform-class-properties',
'transform-object-rest-spread',
'add-module-exports',
'lodash',
'ramda',
'react-require',
[ 'provide-modules', {
'debug': 'debug',
} ],
'babel-root-import',
],
},
}
Also possibly worth note is:
resolve: {
modules: [ SRC, STYLES, 'node_modules' ],
extensions: [
'.js', '.jsx', '.scss',
],
},
And using react-loadable/webpack
Branch | Build failing 🚨 |
---|---|
Dependency | eslint |
Current Version | 3.14.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 8 commits .
e544644
3.14.1
1297635
Build: package.json and changelog update for 3.14.1
791f32b
Fix: brace-style false positive for keyword method names (fixes #7974) (#7980)
d7a0add
Docs: Add ESLint tutorial embed to getting started (#7971)
72d41f0
Fix: no-var autofix syntax error in single-line statements (fixes #7961) (#7962)
b9e5b68
Fix: indent rule crash on sparse array with object (fixes #7959) (#7960)
a7bd66a
Chore: Adding assign/redeclare tests to no-undefined (refs #7964) (#7965)
8bcbf5d
Docs: typo in prefer-promise-reject-errors (#7958)
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | eslint-plugin-import |
Current Version | 2.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint-plugin-import is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 10 commits.
44ca158
update utils changelog
a3728d7
bump eslint-module-utils to v2.1.0
3e29169
bump v2.4.0
ea9c92c
Merge pull request #737 from kevin940726/master
8f9b403
fix typos, enforce type of array of strings in allow option
95315e0
update CHANGELOG.md
28e1623
eslint-module-utils: filePath in parserOptions (#840)
2f690b4
update CI to build on Node 6+7 (#846)
7d41745
write doc, add two more tests
dedfb11
add allow glob for rule no-unassigned-import, fix #671
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Hey all, I made a proper node polyfill for require.ensure - would be cool if this library could somehow automatically import it.
Heres a link if you are interested -
https://github.com/DylanPiercey/require-ensure
Feel free to close the issue or let me know if I can be of help in anyway.
I recently discovered that when you try to use this plug-in with another Babel plug-in, module-resolver, it breaks. That plug-in re-writes the paths of import
statements, for instance transforming "~/src/foo"
to "projectRoot/src/foo"
.
For instance:
// a.js
export const foo = 1;
// b.js
import {foo} from '~/a';
// c.js
import('./b');
results in:
ERROR in ./c.js
Module not found: Error: Can't resolve '~/a' in ...
Presumably this is happening because when c
imports b
this plug-in somehow bypasses the module-resolver plug-in. While this may well be module-resolver's fault, it could also be this library's, so I figured I'd try submitting the issue here first.
Ultimately it would be nice if these two great plug-ins could work together. Thanks.
To my understanding this will load CJS files and have named property access on them? There is ongoing discussion if this is going to be implemented or not. I am hesitant to encourage named properties working. In all proposed interopoperability scenarios however, there is a default
export that maps directly to module.exports
. Something to bear in mind, and perhaps remove named imports until interop is ironed out.
Not to squabble over semantics, but a conversion from import()
to require.ensure()
is really not a dynamic import statement through webpack.
I've already started to see people saying that its possible to perform dynamic imports when that really is 0% supported by webpack (since it is only accomplished through static analysis). Since you folks are pretty well regarded in the OSS technology you publish, I just want to ensure that our webpack user base doesn't have misguided expectations about what is possible.
With that in mind, would you consider renaming this module to be whatwg-import-webpack
instead of dynamic-import-webpack
?
Thanks for providing this awesome workaround to the API. You can track our github issue for implementing the native webpack support for import()
as we may add additional require.ensure features. (webpack/webpack#3098). (It will however, still be statically analyzed).
Actually as I've been writing this I also noticed that @domenic called the proposal [dynamic-loader]
so that is fair that you would call it there.
I would be happy to PR the README to state that this doesn't really perform truly dynamic imports, since webpack doesn't support this.
import(/* webpackChunkName: "plugin" */ './plugin.js')
sets chunk [name]
the same as [id]
, so the output filename is 0.0.js
(in config: chunkFilename: '[id].[name].js'
)
Hello,
While webpack 2 has import, this plugin still can be very valuable...
Can you please add it so that the imported module generates a name for the chunk as require.ensures 3rd argument?
The flaw with WP2 import is that you can't name the chunks. They are trying to resolve that, but who knows when that would be completed.
This plugin has opportunity to quickly provide a way to name the chunks.
Would it make sense to allow for the chunk to be named, with something like import(./foo.js, 'mod_name')
?
Branch | Build failing 🚨 |
---|---|
Dependency |
[babel-preset-airbnb](https://github.com/airbnb/babel-preset-airbnb)
|
Current Version | 2.4.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
babel-preset-airbnb is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 12 commits.
f438196
v2.5.0
82f94a2
[Dev Deps] update eslint-plugin-import
dbdeb2d
[Deps] update babel-preset-env
f1bbda2
[Fix] set "strict" to true.
9749005
[Tests] on node
v10
; use nvm install-latest-npm
c89c008
[Dev Deps] update eslint
, eslint-config-airbnb-base
, eslint-plugin-import
ec3b6cb
[Deps] update babel-preset-env
, babel-plugin-transform-es2015-modules-commonjs
, object.assign
5f6b84d
[Deps] update babel-plugin-transform-object-rest-spread
, babel-plugin-transform-es2015-modules-commonjs
c3e597a
[Dev Deps] update eslint
, eslint-config-airbnb-base
20a15ac
[New] transform ES5 property mutators
17d2bdc
[Deps] update babel-preset-env
482eda6
[Dev Deps] update eslint
, eslint-config-airbnb-base
, eslint-plugin-import
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | babel-preset-airbnb |
Current Version | 2.2.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As babel-preset-airbnb is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 6 commits.
9410812
Version 2.3.0
98c9c1d
Merge pull request #13 from airbnb/babel-preset-env
a3b73f6
Switches to use babel-preset-env
13da4ee
[Tests] npm v4.6+ doesn’t work on node < v1
3065a5c
[Deps] update babel-plugin-syntax-trailing-function-commas
, babel-plugin-transform-es2015-template-literals
, babel-plugin-transform-es3-member-expression-literals
, babel-plugin-transform-es3-property-literals
, babel-plugin-transform-exponentiation-operator
, babel-plugin-transform-jscript
, babel-plugin-transform-object-rest-spread
, babel-preset-es2015
, babel-preset-react
bd811d3
[Dev Deps] update eslint
, eslint-config-airbnb-base
, eslint-plugin-import
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Current implementation never rejects promise. However, in the spec, there is a failure path when a module has failed to load, it should be rejected.
I understand, that it will be hard to implement due to limitations of Webpack 1.x, but I'd like to create this issue to look for a possible way to work around this.
I couldn't make dynamic-import-webpack
work with [email protected]
even though it works fine in the version 6.24.0
. Is anyone else having the same issue?
ie, remove the .default
when __esModule
is present?
What does the import()
spec say?
Most of Babel's transformation plugins internally depend on their syntax plugins so people don't have to list both, e.g. https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-class-properties/src/index.js#L24
Seems like that could benefit this plugin too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.