Comments (8)
I'm not sure how to do this without patching webpack itself. Webpack2 added error handling to require.ensure
, but it was never added to the 1.x branch.
from babel-plugin-dynamic-import-webpack.
And Webpack 1 will never get error handling for require.ensure
from babel-plugin-dynamic-import-webpack.
What currently happens in webpack 1 when the module fails to load via require.ensure
?
from babel-plugin-dynamic-import-webpack.
Nothing happens. Successful callback is never called.
There was ticket in webpack, closed with the commit into 2.0
branch: webpack/webpack#758
Also, there is a plugin, that does some monkey patching of Webpack1 internals to get this: https://github.com/richardscarrott/require-error-handler-webpack-plugin
Finally, it is also possible to add a timeout, like it was done in Require.js:
new Promise((resolve, reject) => {
require.ensure([], require => {
resolve(require('test-module'));
});
setTimeout(() => reject(new Error('module loading was timed out')), timeoutInterval);
});
from babel-plugin-dynamic-import-webpack.
FYI, I just submitted a PR to Webpack v2.2 to add require.ensure error handling: webpack/webpack#4069
from babel-plugin-dynamic-import-webpack.
With Webpack2 it is not a problem. There is already native support of import()
expression.
from babel-plugin-dynamic-import-webpack.
import() does add error handling, but doesn't support named chunks, or recursive code splitting, see my comment here:
webpack/webpack#3364 (comment)
from babel-plugin-dynamic-import-webpack.
Neither of those things are part of the import() spec so they're irrelevant here.
from babel-plugin-dynamic-import-webpack.
Related Issues (20)
- Minimal sample code snippet using `import()` or link to spec
- CJS interop? HOT 19
- An in-range update of babel-cli is breaking the build 🚨 HOT 5
- An in-range update of eslint is breaking the build 🚨 HOT 1
- add chunk name HOT 1
- Default export is not picked up properly HOT 11
- add name to require.ensures HOT 7
- An in-range update of eslint-plugin-import is breaking the build 🚨 HOT 1
- An in-range update of babel-preset-airbnb is breaking the build 🚨 HOT 3
- Incompatible with lastest babel-core release HOT 1
- Unable to use import() with magic comments HOT 6
- An in-range update of eslint is breaking the build 🚨 HOT 2
- not work in webpack3 HOT 1
- Plugin Doesn't Work With babel-plugin-module-resolver HOT 5
- 1.0.2 breaks code splitting HOT 12
- Version 10 of node.js has been released
- An in-range update of babel-preset-airbnb is breaking the build 🚨 HOT 6
- Can I use it in React Native? HOT 1
- An in-range update of safe-publish-latest is breaking the build 🚨 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-dynamic-import-webpack.