Open avra-m3 opened 2 years ago
Newer uuid versions are not an option due to https://github.com/swc-project/swc/issues/3406
I am facing the same issue. Here is the minimal repro I can produce:
@swc/cli: 0.1.57
@swc/core: 1.2.242
macOS Monterey
const { config } = require('@swc/core/spack');
module.exports = config({
entry: {
web: __dirname + '/cryptotester.ts',
},
output: {
path: __dirname + '/dist',
},
options: {
swcrc: true,
},
target: 'node',
module: {},
});
import { v4 } from 'uuid';
export function createHash() {
return v4();
}
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"baseUrl": "./src",
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true,
"dynamicImport": false
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"target": "es2020",
"loose": false,
"externalHelpers": false
},
"module": {
"type": "commonjs"
},
"exclude": [".*.test.ts$", ".*.spec.ts$"],
"minify": false,
"sourceMaps": true
}
spack
thread '<unnamed>' panicked at 'internal error: entered unreachable code: module item found but is_es6 is false: ExportNamed(NamedExport { span: Span { lo: BytePos(148), hi: BytePos(188), ctxt: #0 }, specifiers: [Named(ExportNamedSpecifier { span: Span { lo: BytePos(157), hi: BytePos(170), ctxt: #0 }, orig: Ident(Ident { span: Span { lo: BytePos(157), hi: BytePos(164), ctxt: #15 }, sym: Atom('default' type=static), optional: false }), exported: Some(Ident(Ident { span: Span { lo: BytePos(168), hi: BytePos(170), ctxt: #11 }, sym: Atom('v1' type=inline), optional: false })), is_type_only: false })], src: Some(Str { span: Span { lo: BytePos(178), hi: BytePos(187), ctxt: #0 }, value: Atom('./v1.js' type=inline), raw: Some("'./v1.js'") }), type_only: false, asserts: None })', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_bundler-0.179.0/src/bundler/chunk/cjs.rs:142:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: panic detected: internal error: entered unreachable code: module item found but is_es6 is false: ExportNamed(NamedExport { span: Span { lo: BytePos(148), hi: BytePos(188), ctxt: #0 }, specifiers: [Named(ExportNamedSpecifier { span: Span { lo: BytePos(157), hi: BytePos(170), ctxt: #0 }, orig: Ident(Ident { span: Span { lo: BytePos(157), hi: BytePos(164), ctxt: #15 }, sym: Atom('default' type=static), optional: false }), exported: Some(Ident(Ident { span: Span { lo: BytePos(168), hi: BytePos(170), ctxt: #11 }, sym: Atom('v1' type=inline), optional: false })), is_type_only: false })], src: Some(Str { span: Span { lo: BytePos(178), hi: BytePos(187), ctxt: #0 }, value: Atom('./v1.js' type=inline), raw: Some("'./v1.js'") }), type_only: false, asserts: None })] {
code: 'GenericFailure'
}
Not sure if this helps, esbuild
was able to build cryptotester.ts
just fine. I can provide the built output of the file if need be, but because it is quite long I will hold off...
After some more digging, it seems like if I set module: { type: 'es6' }}
in my .swcrc
, the error goes away, so it's likely related to CommonJS?
Describe the bug
The input code when bundled with spack generates
TypeError: (0 , _uuid.v4) is not a function
.Input code
Config
.swcrc
spack.config.js
Playground link
No response
Expected behavior
Output a uuid
Actual behavior
Version
1.2.224
Additional context
generated bundle code