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

Upgrade to v7 stops module concatentation from working #8960

Closed
jacobwindsor opened this issue Nov 1, 2018 · 8 comments
Closed

Upgrade to v7 stops module concatentation from working #8960

jacobwindsor opened this issue Nov 1, 2018 · 8 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jacobwindsor
Copy link

v7 Regression

First check out: https://new.babeljs.io/docs/en/next/v7-migration.html
Also a partial upgrade tool: https://github.com/babel/babel-upgrade

Potential Commit/PR that introduced the regression
I'm unsure if this is related to a change in babel or babel loader. I would guess babel but have been unable to find a PR related to it. However, PR #660 in babel-loader is related.

Describe the regression
When upgrading to babel 7, webpack's module concatenation does not behave correctly. Everything builds okay but results in a runtime error:

image

Disabling optimization.concatenateModules in the webpack production config fixes this. optimization.concatenateModules is disabled by default in the development mode so this issue only arises in production.

As expected from previously mentioned babel-loader PR, setting modules to commonjs in the babel config also fixes the issue.

Both of the above fixes just force module concatenation to be disabled.

Babel Configuration (.babelrc, package.json, cli command)

{
    "presets": [["@babel/env", {
        "targets": {
            "browsers": ["last 2 versions", "ie >= 9"]
        }
        , "useBuiltIns": "entry"
    }]]
    , "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

Expected behavior/code
Webpack's module concatenation should behave as expected with Babel 7.

Environment

  • Babel version(s): 7.0.0
  • Node/npm version: 8.9.4
  • OS: windows 10
  • babel-loader: 8.0.4
  • How you are using Babel: loader
@babel-bot
Copy link
Collaborator

Hey @jacobwindsor! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@jacobwindsor
Copy link
Author

Module concatenation would have been disabled before I upgraded to babel 7 too. I hadn't disabled module transformation in the babel config.

So, this might not be a babel issue but I'm unable to confirm whether it's a webpack issue. I'll leave it here in the hope that someone might have an idea.

@loganfsmyth
Copy link
Member

Not sure specifically, but maybe this is related to webpack/webpack#4039 (comment)? Are you compiling any CommonJS files in your project? If not, it's possible you're doing something else that Webpack doesn't expect. I'm not sure, I'd have to see the actual code that throws the error.

@jacobwindsor
Copy link
Author

Thanks for the tip @loganfsmyth

Unfortunately, I can't share the code. It doesn't seem like our project is subject to any of those two conditions. We are only transpiling our source code and not node_modules and are using harmony imports/exports everywhere. The only thing I can think is that we have one file that contains many harmony imports and one require statement. The require statement is needed as it is importing a commonjs module.

I have tried adding sourceType: unambigous but it does not help.

@danez
Copy link
Member

danez commented Nov 18, 2018

Can you try adding modules: false to the preset-env config? In theory babel should autodetect that webpack supports esmodules and set this configuration, but if this fixes the problem, then we definitely know it is a problem in babel.

{
    "presets": [["@babel/env", {
        "targets": {
            "browsers": ["last 2 versions", "ie >= 9"]
        }
        , "modules": false
        , "useBuiltIns": "entry"
    }]]
    , "plugins": ["@babel/plugin-syntax-dynamic-import"]
}

@jacobwindsor
Copy link
Author

@danez That does not fix the issue. Still exactly the same problem. Why does this mean it;s a babel issue?

@nicolo-ribaudo
Copy link
Member

If not transforming modules with Babel doesn't solve the issue, then it is a bug with webpack.

@jacobwindsor
Copy link
Author

Closed and moving to webpack repo

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 21, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants