unplugin / unplugin-turbo-console

🚀 Improve the Developer Experience of console
https://utc.yuy1n.io
MIT License
526 stars 12 forks source link

error on using package has `import ... from ... with {type: 'json'}` #35

Closed naramdash closed 5 months ago

naramdash commented 5 months ago

Describe the bug

image

If i use a package has import with {type: 'json'}, turbo-console raises an error related to babel parser.

Scripts vite build, and vite dev work well without turbo-console.

You can reproduce this error with a github repo link on reproduction.

Reproduction

https://github.com/naramdash/test-turbo-import-with-json

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (22) x64 Intel(R) Core(TM) Ultra 9 185H
    Memory: 18.13 GB / 30.88 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.volta/tools/image/node/20.14.0/bin/node
    Yarn: 4.2.2 - ~/.volta/tools/image/yarn/4.2.2/bin/yarn
    npm: 10.7.0 - ~/.volta/tools/image/node/20.14.0/bin/npm
    pnpm: 9.1.3 - ~/.volta/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.61

Used Package Manager

npm

Validations

yuyinws commented 5 months ago

Thanks for your report. It should been fixed on https://github.com/unplugin/unplugin-turbo-console/releases/tag/v1.8.7

yuyinws commented 4 months ago

Hi, just a notice. On the new version(v1.8.8), we expose babel parser plugins to the options. So you need config importAttributes manually like this:

export default defineConfig({
  plugins: [
    TurboConsole({
      babelParserPlugins: [
        'importAttributes',
      ]
    }),
  ]
})
naramdash commented 4 months ago

Thank you @yuyinws , It works good!