oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.12k stars 2.76k forks source link

Cannot access 'default' before initialization. in `Vite` #13338

Open Gn3po4g opened 2 months ago

Gn3po4g commented 2 months ago

What version of Bun is running?

1.1.24

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

add unocss() into vite plugins and run bunx --bun vite

example:

export default defineConfig({
  plugins: [
    unocss(),
  ]
}

What is the expected behavior?

vite server starts.

What do you see instead?

ReferenceError: Cannot access 'default' before initialization.
      at E:\projects\app\node_modules\importx\node_modules\jiti\dist\jiti.cjs:1:180987
      at jitiInteropDefault (E:\projects\app\node_modules\importx\node_modules\jiti\dist\jiti.cjs:1:181414)
      at E:\projects\app\node_modules\importx\node_modules\jiti\dist\jiti.cjs:1:185158

Additional information

bunx --bun remix vite:dev output:

1 | (()=>{var __webpack_modules__={"./node_modules/.pnpm/create-require@1.1.1/node_modules/create-require/create-require.js":(module,__unused_webpack_exports,__webpack_require__)=>{const nativeModule=__webpack_require__("module"),path=__webpack_require__("path"),fs=__webpack_require__("fs");module.exports=function(filename){return filename||(filename=process.cwd()),function(path){try{return fs.lstatSync(path).isDirectory()}catch(e){return!1}}(filename)&&(filename=path.join(filename,"index.js")),nativeModule.createRequire?nativeModule.createRequire(filename):nativeModule.createRequireFromPath?nativeModule.createRequireFromPath(filename):function(filename){const mod=new nativeModule.Module(filename,null);return mod.filename=filename,mod.paths=nativeModule.Module._nodeModulePaths(path.dirname(filename)),mod._compile("module.exports = require;",filename),mod.exports}(filename)}},"./node_modules/.pnpm/mlly@1.7.1/node_modules/mlly/dist lazy recursive":module=>{function webpackEmptyAsyncContext(req){return Promise.resol | ... truncated 
xbears commented 2 months ago

+1

wiinxt commented 2 months ago

I had a similar error with "@unocss/nuxt" but it seems to be fixed with bun v1.1.26 My bad, i forget the --bun ... Error is always here

chrisbbreuer commented 4 weeks ago

@unocss/eslint-plugin also breaks/hangs. Assuming it's from the same issue source. (I keep reverting to v0.61.0 and there it works splendidly)

Running into this in the Stacks codebase