Closed thomas-short closed 2 years ago
Can you provide the full ntm debug log? From next dev/build
to the crash?
Seems nothing too interesting. Just a lot of logs for each file it transpiles.
info - Creating an optimized production build .next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/translator-client/index.js
next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/public-web-common/dist/translator/index.js
next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/public-web-common/dist/translator/index.js
next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/puco-react/dist/src/index.js
...
...
info - Creating an optimized production build ..next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/public-web-common/dist/_virtual/_commonjsHelpers.js
next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/puco-react/dist/index.js
next-transpile-modules - transpiled: /git/project/node_modules/@Privatepackage/public-web-common/dist/translator/index.js
info - Creating an optimized production build
Right after this point is the webpack error
I tried by just bumping one version of next so from 12.1.0
to 12.1.1
and got the error.
./node_modules/@Privatepackage/puco-react/dist/index.js
Error: error: the name `ProjectInterface` is defined multiple times
|
12757 | function ProjectInterface() { return {}; }
| ---------------- previous definition of `ProjectInterface` here
...
28120 | var ProjectInterface = (function () {
| ^^^^^^^^^^^^^^^^ `ProjectInterface` redefined here
Import trace for requested module:
./src/pages/blog/index.tsx
And just before that point logs from ntm
show no issue:
...
info - Creating an optimized production build .next-transpile-modules - transpiled: /node_modules/@Privatepackage/puco-react/dist/index.js
next-transpile-modules - transpiled: /node_modules/@Privatepackage/public-web-common/dist/translator/index.js
info - Creating an optimized production build
hmm when I check the file directly: ./node_modules/@Privatepackage/puco-react/dist/index.js
I do see it has:
12757 function ProjectInterface() { return {}; }
...
28120 var ProjectInterface = (function () {
So problem is already there before it gets transpiled by your package 🤔 I manually removed one of the declarations and now the build works 😵 So indeed not an issue with your package and we can close this issue. But very odd it worked fine with previous version of Next...
I will have to figure out why rollup declares the same function twice.
Seems nothing too interesting. Just a lot of logs for each file it transpiles.
please can you include the full log? It's really important, especially the beginning. Feel free to hide the secret bits, but I really need the full terminal log 😅
Are you trying to transpile a local package or an npm package? Private NPM package. It's an FE library using ESM.
Describe the bug After running build command:
NEXT_TELEMETRY_DISABLED=1 next build && tsc --project tsconfig.server.json
The build fails with a webpack error, which is huge unfortunately, and makes it hard to read logs that come from
next-transpile-modules
debug, but didn't notice any issues in the logs fornext-transpile-modules
.The webpack error is as follows: (logs all 28k lines 😢 )
To Reproduce Hard to provide this as npm package is private but happy to provide any info about it that might help figure out the issue
Expected behavior Something changed between version 12.1.0 and 12.1.6 to cause the issue. Will try to sift through the changelog to see if there are any clues there.
Setup
next-transpile-modules
version: 9.0.0npm
version: 6.14.16Rollup config for FE npm package:
package.json for FE npm package contains:
next.config.js webpack configuration:
Additional context I cannot say for sure the issue is with next-transpile-modules
What I did was simplify our project down to a very simple form and I narrowed the cause to when we import a npm package that uses ESM.
So it's clear when I just import from this package:
import { someComponent } from 'external-fe-library';
Then webpack build breaks with the error I previously linked. This is a npm package that we transpile using this package:
withTM(['external-fe-library']).
If I remove it from withTM then the build fails with error "ReferenceError: exports is not defined in ES module scope", which is what this package helped to solve in the first place.
The build seems to be ok with other NPM packages that we transpile, so it might be some edge case with this particular package that we are using.
Happy to provide any more info if I can.