Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing resolving a module at runtime #15518

Closed
indiketa opened this issue Mar 11, 2022 · 5 comments · Fixed by #15536
Closed

Failing resolving a module at runtime #15518

indiketa opened this issue Mar 11, 2022 · 5 comments · Fixed by #15536

Comments

@indiketa
Copy link

indiketa commented Mar 11, 2022

Bug report

What is the current behavior?
Webpack compilation finishes without any error nor warning.
At runtime an error is thrown while importing a module through a dynamic import.

"User-space" code router.js:259:

pantalla = await import(
  /* webpackChunkName: "generales" */
  /* webpackMode: "lazy-once" */
  `pantallas/generales/${idPantalla}.js`);

The following error is thrown:

  router.js:368 TypeError: __webpack_require__.t is not a function
    at |chunkName: generales|groupOptions: {}|namespace object:20:1
    at async cargarPantalla (router.js:259:1)

This is the webpack-generated function causing the error:

function webpackAsyncContext(req) {
	return webpackAsyncContextResolve(req).then(id => {
		return __webpack_require__.t(id, fakeMap[id] | 16);
	});
}

t does not exist into __webpack_require__.
A needed function is deleted while compiling/optimizing or mangling is not working properly, i don't know.

What is the expected behavior?
The function should exist, this is an error into webpack module resolution code. No clues or workarounds.

Other relevant information:
webpack version: 5.70.0
Node.js version: 16.14
Operating System: Fedora 35
Additional tools: --

@vankop
Copy link
Member

vankop commented Mar 12, 2022

could you provide a reproducible repo?

@indiketa
Copy link
Author

Obviously it only fails in one of the several projects I use in webpack, I can't publish all the source code.

All these plugins are used:

    "devDependencies": {
        "clean-webpack-plugin": "^4.0.0",
        "css-loader": "^6",
        "css-minimizer-webpack-plugin": "^3",
        "eslint": "^8",
        "eslint-webpack-plugin": "^3",
        "html-loader": "^3",
        "html-webpack-plugin": "^5.5",
        "mini-css-extract-plugin": "^2",
        "sass": "^1",
        "sass-loader": "^12",
        "string-replace-loader": "^3",
        "style-loader": "^3",
        "terser-webpack-plugin": "^5",
        "webpack": "^5",
        "webpack-bundle-analyzer": "^4",
        "webpack-cli": "^4"
    },

Our approach will be to disable plugins/loaders one by one to detect which is causing the issue (maybe the source... but in webpack4 works perfectly).

Is there any way to disable webpack generated code obfuscation/mangling for debugging purposes?

@indiketa
Copy link
Author

I think i've narrowed the error in the webpack dynamic import module. Preparing a minimal example repo...

@indiketa
Copy link
Author

indiketa commented Mar 14, 2022

The issue is:
When a module exports nothing inside a dynamic import chunk, loading another module inside the chunk will make entire loading fail.

See this repo:
https://github.com/indiketa/webpack5-dynamic-import-issue.git

@vankop
Copy link
Member

vankop commented Mar 14, 2022

thanks. I found problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants