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

Regression 1.7.3 to 1.7.4: __nccwpck_require__ is not defined #188

Open
vieira opened this issue May 21, 2024 · 2 comments
Open

Regression 1.7.3 to 1.7.4: __nccwpck_require__ is not defined #188

vieira opened this issue May 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vieira
Copy link

vieira commented May 21, 2024

After updating from @vercel/webpack-asset-relocator-loader 1.7.3 to 1.7.4 the build still succeeds but the generated bundle now fails to start with the following error:

/Users/.../dist/index.js:198193
const googleProtoFilesDir = __nccwpck_require__.ab + "protos";
                            ^

ReferenceError: __nccwpck_require__ is not defined
    at 38020 (/Users/.../api/dist/index.js:198193:29)
    at __webpack_require__ (/Users/.../dist/index.js:774516:42)
    at 52013 (/Users/.../api/dist/index.js:198899:16)
    at __webpack_require__ (/Users/.../dist/index.js:774516:42)
    at new LanguageServiceClient (/Users/.../dist/index.js:50263:27)
    at 80046 (/Users/.../dist/index.js:661168:16)
    at __webpack_require__ (/Users/.../dist/index.js:774516:42)
    at 49801 (/Users/.../dist/index.js:661353:38)
    at __webpack_require__ (/Users/.../dist/index.js:774516:42)
    at 96739 (/Users/.../dist/index.js:660922:49)

Relevant webpack configuration:

const webpack = require('webpack');

module.exports = {
  entry: './index.js',
  target: 'node20',
  node: false,
  devtool: false,
  resolve: {
    mainFields: ['main', 'module'],
  },
  // ...
  optimization: {
    minimize: false,
  },
  module: {
    rules: [
      {
        test: /\.mjs$/,
        type: 'javascript/auto',
      },
      {
        test: /\.m?js?$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: { rootMode: 'upward' },
        },
      },
      {
        test: /\.(m?js|node)$/,
        parser: { amd: false },
        use: {
          loader: '@vercel/webpack-asset-relocator-loader',
          options: {},
        },
      },
    ],
  },
  stats: {
    warnings: false,
  },
}

Downgrading to 1.7.3 fixes the issue, without any other changes.

@styfle styfle added the bug Something isn't working label May 22, 2024
@styfle
Copy link
Member

styfle commented May 22, 2024

This might be related to the upgrade to ncc. I was surprised to find it there because we have a circular dependency:

  • webpack-asset-relocator-loader depends on ncc
  • ncc depends on webpack-asset-relocator-loader

I was forced to upgrade ncc in this repo since it was using a really old version that didn't support newer Node.js versions.

@guybedford Do you recall why ncc is needed? Can we drop it?

@linonetwo
Copy link

Thank you! Downgrade to @vercel/webpack-asset-relocator-loader 1.7.3 fix this for me, thank you for posting this issue so I can google here!

alfredomariamilano added a commit to alfredomariamilano/webpack-asset-relocator-loader that referenced this issue Oct 8, 2024
Remove the use of the deprecated Webpack MainTemplate.
If `__nccwpck__` is not present, fall back to `__webpack_require__`.
It fixes the regression from 1.7.3 to 1.7.4 vercel#188 and it also allows for compatibility with `rspack` https://github.com/web-infra-dev/rspack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants