question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack5: mod is not defined

See original GitHub issue

Bug report

What is the current behavior?

Building a project in production mode using webpack5 results in a mod is not defined error at runtime.

If you build with development mode, no errors will occur at runtime. In webpack4 this error does not occur when building in production mode.

Also, when building with webpack4, there are no deprecation warnings.

So I think this is a bug in webpack5.

AAA1139D-F2EF-486C-81CF-DF810A18F7A5

If the current behavior is a bug, please provide the steps to reproduce.

I haven’t created a minimal reproducible repository yet, but here is the actual my project config.

https://github.com/syuilo/misskey/blob/develop/webpack.config.ts

What is the expected behavior?

No runtime error

Other relevant information: webpack version: 5.0.0-beta.13 Node.js version: 13.7.0 Operating System: Windows10 Additional tools:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
sogehigecommented, Mar 7, 2020

I’ve got this error as well on both modes ReferenceError: mod is not defined which is

in production mode:

        /***/
        70651: /***/
        ((__unused_webpack_module,__unused_webpack___webpack_exports__,__webpack_require__)=>{

            "use strict";
            /* harmony import */
            var _node_modules_vue_style_loader_index_js_node_modules_css_loader_dist_cjs_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_vue_loader_lib_index_js_vue_loader_options_login_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(47469);
            /* harmony import */
            var _node_modules_vue_style_loader_index_js_node_modules_css_loader_dist_cjs_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_vue_loader_lib_index_js_vue_loader_options_login_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/
            __webpack_require__.n(_node_modules_vue_style_loader_index_js_node_modules_css_loader_dist_cjs_js_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_vue_loader_lib_index_js_vue_loader_options_login_vue_vue_type_style_index_0_lang_css___WEBPACK_IMPORTED_MODULE_0__);
            /* unused harmony default export */
            var _unused_webpack_default_export = (mod); /* <==== this line */

            /***/

This is caused by inline <style> in .vue file for me. It seems to me like issue with tree shaking and side effects?

Other relevant information: webpack version: 5.0.0-beta.13 Node.js version: 13.10.1 Operating System: Windows10 Additional tools:

1reaction
sodateacommented, Mar 12, 2020

I think so

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swiper 8 with Webpack 5: Class not defined - Stack Overflow
I'm trying to use Swiper 8 with Webpack 5. In my Webpack config i defined two entry points ...
Read more >
Module Federation - webpack
Remote modules are modules that are not part of the current build but are loaded at runtime from a remote container. Loading remote...
Read more >
How To Fix ReferenceError require is not defined in JavaScript
In Node.js, require is a function that is available to use JavaScript modules elsewhere. The syntax for using require is defined by the...
Read more >
referenceerror: webpack is not defined - You.com | The AI ...
webpack : Uncaught ReferenceError: require is not defined ... webpack --mode development --config webpack.dev.config.js --watch", "devBuild": "set ...
Read more >
Fix "require is not defined" in JavaScript/Node - Stack Abuse
You can use a bundler like Webpack, which compiles your JavaScript code into a format that is compatible with the browser. Internally, a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found