Coder Social home page Coder Social logo

Comments (8)

kesne avatar kesne commented on May 18, 2024

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.

chicoxyzzy avatar chicoxyzzy commented on May 18, 2024

And Webpack 1 will never get error handling for require.ensure

from babel-plugin-dynamic-import-webpack.

ljharb avatar ljharb commented on May 18, 2024

What currently happens in webpack 1 when the module fails to load via require.ensure?

from babel-plugin-dynamic-import-webpack.

just-boris avatar just-boris commented on May 18, 2024

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.

jharris4 avatar jharris4 commented on May 18, 2024

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.

just-boris avatar just-boris commented on May 18, 2024

With Webpack2 it is not a problem. There is already native support of import() expression.

from babel-plugin-dynamic-import-webpack.

jharris4 avatar jharris4 commented on May 18, 2024

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.

ljharb avatar ljharb commented on May 18, 2024

Neither of those things are part of the import() spec so they're irrelevant here.

from babel-plugin-dynamic-import-webpack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.