Do you want to request a feature or report a bug?
BUG
What is the current behavior?
require.resolveWeak() can't statically determine module string passed to it as well as import().then.
modules[moduleId] is undefined here:
modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
the moduleId is "./src/components recursive ^\.\/.*$"
Here's the trace:
TypeError: Cannot read property 'call' of undefined
__webpack_require__
http://localhost:3000/static/bootstrap.js:694:29
fn
http://localhost:3000/static/bootstrap.js:115:20
resolve
http://localhost:3000/static/main.js:35453:34
requireSync
http://localhost:3000/static/main.js:80:58
webpackJsonp.../async-module/src/index.js.exports.default
http://localhost:3000/static/main.js:165:10
Loadable
http://localhost:3000/static/main.js:4176:47
getComponent
http://localhost:3000/static/main.js:35434:35
new App
http://localhost:3000/static/main.js:35379:16
http://localhost:3000/static/main.js:12070:18
measureLifeCyclePerf
http://localhost:3000/static/main.js:11850:12
If the current behavior is a bug, please provide the steps to reproduce.
For example, try:
require.resolveWeak(`${+new Date() % 2 ? './Example' : './Loading'}`)
What is the expected behavior?
The expected behavior is that resolveWeak will return the moduleId of the corresponding module. The weird thing is that it works when using Webpack on the server, but in the browser (Chrome) it does not work.
In addition, the following works:
import(/* webpackChunkName: "[request]" */ `${+new Date() % 2 ? './Example' : './Loading'}`).then(...
If this is a feature request, what is motivation or use case for changing the behavior?
The motivation and use case for this is for tools like React Loadable and React Universal Component which allow for async-loading + server-side rendering of the same component. Currently such tools don't allow for dynamic component selection (because it depends on resolveWeak for synchronous loading if the module is already available).
If it was just a case of using import().then, such expressions would work. But resolveWeak is needed to make the server-side synchronous rendering magic happen, as well as the synchronous rendering on initial load in the browser if the corresponding chunks are embedded before main.
This is a very important feature for the React Loadable and React Universal Component community and any other future async packages.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
VERSION: 2.6.1 + 3.0.0
NODE: 7.7.2
OSX
Do you want to request a feature or report a bug?
BUG
What is the current behavior?
require.resolveWeak()can't statically determine module string passed to it as well asimport().then.modules[moduleId] is undefined here:
Here's the trace:
If the current behavior is a bug, please provide the steps to reproduce.
For example, try:
What is the expected behavior?
The expected behavior is that
resolveWeakwill return themoduleIdof the corresponding module. The weird thing is that it works when using Webpack on the server, but in the browser (Chrome) it does not work.In addition, the following works:
If this is a feature request, what is motivation or use case for changing the behavior?
The motivation and use case for this is for tools like React Loadable and React Universal Component which allow for async-loading + server-side rendering of the same component. Currently such tools don't allow for dynamic component selection (because it depends on
resolveWeakfor synchronous loading if the module is already available).If it was just a case of using
import().then, such expressions would work. ButresolveWeakis needed to make the server-side synchronous rendering magic happen, as well as the synchronous rendering on initial load in the browser if the corresponding chunks are embedded beforemain.This is a very important feature for the React Loadable and React Universal Component community and any other future async packages.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
VERSION: 2.6.1 + 3.0.0
NODE: 7.7.2
OSX