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

ReferenceError on client render in production build using SWC minifier #66237

Closed
georgwittberger-telekom-mms opened this issue May 27, 2024 · 1 comment · Fixed by vercel/turborepo#8272
Assignees
Labels
bug Issue was opened via the bug report template. locked Module Resolution Module resolution (CJS / ESM, module resolving) SWC Related to minification/transpilation in Next.js.

Comments

@georgwittberger-telekom-mms

Link to the code that reproduces this issue

https://github.com/georgwittberger-telekom-mms/nextjs-lyne-swc-error-repro

To Reproduce

  1. Build project using npm run build.
  2. Start test server using npm run start.
  3. Open page on http://localhost:3000
  4. View browser console output.

Current vs. Expected behavior

Current behavior:

During client render a ReferenceError is thrown as soon the code attempts to use a certain module export. This is caused by the minified Webpack module exports referencing an identifier which does not exist (see additional context).

Expected behavior:

No error. Minified JavaScript identifiers pointing to the correct values.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
  Available memory (MB): 32434  
  Available CPU cores: 16       
Binaries:
  Node: 20.10.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3
  eslint-config-next: 14.2.3    
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: export

Which area(s) are affected? (Select all that apply)

Module Resolution, SWC

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

The following error appears in the browser console:

ReferenceError: e is not defined
    at Object.jU (848-7d911d46e30bd3f0.js:16:18331)
    at new k (848-7d911d46e30bd3f0.js:16:7592)
    at 9705 (848-7d911d46e30bd3f0.js:16:7777)
    at d (webpack-4b7c5c3f98de81bb.js:1:151)
    at 9393 (page-e76bcc040321554e.js:1:223)
    at Function.d (webpack-4b7c5c3f98de81bb.js:1:151)

The identifier e which is missing here is the exported isBrowser function of the module node_modules/@sbb-esta/lyne-components/development/core/dom.js.

// Minified code of "node_modules/@sbb-esta/lyne-components/development/core/dom.js"
3712: function(t, o, r) {
        r.d(o, {
            $Q: function() {
                return l
            },
            Ev: function() {
                return i
            },
            e_: function() {
                return s
            },
            jU: function() {
                return e    // <-- ReferenceError: e is not defined
            }
        });
        try {
            "u" > typeof Intl && Intl.v8BreakIterator
        } catch (t) {}
        // This variable "n" (the "isBrowser" function) is what should be returned by "jU" function above
        let n = ()=>"object" == typeof document && !!document
          , s = ()=>n() && document.documentElement.getAttribute("dir") || "ltr";
        function i(t, o, r) {
            r ? t.setAttribute(o, r) : t.removeAttribute(o)
        }
@georgwittberger-telekom-mms georgwittberger-telekom-mms added the bug Issue was opened via the bug report template. label May 27, 2024
@github-actions github-actions bot added Module Resolution Module resolution (CJS / ESM, module resolving) SWC Related to minification/transpilation in Next.js. labels May 27, 2024
@kdy1 kdy1 self-assigned this May 28, 2024
kdy1 added a commit to swc-project/swc that referenced this issue Jun 1, 2024
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Module Resolution Module resolution (CJS / ESM, module resolving) SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants