Open bilinenkisi opened 1 year ago
Also seeing this with oclif
warn: Invalid source index value
/home/alex/workspace/rupurt/eve/node_modules/@oclif/core/lib/index.js:1:0 1warn: Unexpected token '*'. import call expects one or two arguments.
at /home/alex/workspace/rupurt/eve/node_modules/@oclif/core/lib/index.js:3:11
1 | (function (resolvedSpecifier) {"use strict";
^
warn: Import named 'Command' not found in module '/home/alex/workspace/rupurt/eve/node_modules/@oclif/core/lib/index.js'.
at loadCJS2ESM (:1:20)
at requireESM (:1:20)
at overridableRequire (:1:20)
at compiled://root/broker:160205:91
at processTicksAndRejections (:61:76)
I am also seeing this with React@18.2
in a compiled binary -- but it's a little confusing because it points me to this file as the origin of the error: node_modules/react/jsx-dev-runtime.js:3:39
which looks like this:
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
} else {
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
}
Using bun to run the source files directly does not produce this error.
Environment:
Same here, I even tried on two different computers. One with Fedora and another with Ubuntu.
Here's the code I used :
index.js
import module1 from "./module1"
module1.test()
> module1.js
import module2 from "./module2"
module.exports = module2
> module2.js
function test() { console.log("test") }
module.exports = {"test": test}
The error I got :
1 | import module2 from "./module2" 2 | 3 | module.exports = module2 ^ SyntaxError: Unexpected identifier 'module2'. import call expects one or two arguments. at /home/ubuntu/test/module1.js:3:0
Yep : Any access to module
into the code base produces this crash on import
.
We have updated the error message to be more clear in the next release.
~~To fix this, don’t use import and module in the same file. Use require
. Bun supports import and requiring the same file, but not import and other CommonJs features because it gets more ambiguous what the right thing to do is. ~~
Edit: this needs to be addressed differently for bun build --compile when the entry point is CommonJS
What version of Bun is running?
1.0.3+25e69c71e70ac8a0a88f9cf15b4057bd7b2a633a
What platform is your computer?
Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Install @keyv/redis package. And init a project for typescript with bun then use @keyv/redis package. after that compile the project with
bun build --compile <the typescript file> --outfile=<out file name>
after compilation run the outputWhat is the expected behavior?
Works with no errors
What do you see instead?
/node_modules/@keyv/redis/dist/index.js:1:0 2SyntaxError: Unexpected token '*'. import call expects one or two arguments.
Additional information
No response