Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

You may need an additional loader to handle the result of these loaders. ./node_modules/@nuxt/bridge/dist/runtime/composables/cookie.mjs #1281

Closed
medz opened this issue Aug 10, 2024 · 1 comment · Fixed by #1283

Comments

@medz
Copy link

medz commented Aug 10, 2024

Environment

  • Operating System: Darwin
  • Node Version: v22.6.0
  • Nuxt Version: 2.18.1
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: npm@10.8.2
  • Builder: webpack
  • User Config: bridge, vite, head, css, plugins, components, buildModules, moment, modules, axios, proxy, build, vue, router, serverHandlers, devServerHandlers, devServer, typescript, nitro
  • Runtime Modules: @nuxtjs/axios@5.13.6, @nuxtjs/proxy@2.1.0
  • Build Modules: (), @nuxtjs/moment@1.6.1, @nuxt/bridge@3.3.1

Reproduction

https://stackblitz.com/edit/github-fmzbfj?file=nuxt.config.ts

Describe the bug

I am trying to upgrade Nuxt2 to Nuxt3, and I use @nuxt/bridge to assist the upgrade (vue2 has too many files and cannot be upgraded directly)

When I come to the second step to enable TypeScript, an error is reported:

✖ Client
Compiled with some errors in 218.74ms

✔ Server
Compiled successfully in 197.37ms

ERROR Failed to compile with 1 errors friendly-errors 22:57:23

ERROR in ./node_modules/cookie-es/dist/index.mjs friendly-errors 22:57:23

Module parse failed: Unexpected token (22:12) friendly-errors 22:57:23

File was processed with these loaders:
* ./node_modules/unplugin/dist/webpack/loaders/transform.js
* ./node_modules/unplugin/dist/webpack/loaders/transform.js You may need an additional loader to handle the result of these loaders. | } | const key = str.slice(index, eqIdx).trim(); > if (opt?.filter && !opt?.filter(key)) { | index = endIdx + 1; | continue; friendly-errors 22:57:23 @ ./node_modules/@nuxt/bridge/dist/runtime/composables/cookie.mjs 13:0-45 112:11-16 118:11-20 122:9-18 @ ./.nuxt/imports.mjs @ ./.nuxt/capi.plugin.mjs @ ./.nuxt/index.js @ ./.nuxt/client.js @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js 

Additional context

import { defineNuxtConfig } from '@nuxt/bridge';

export default defineNuxtConfig({
bridge: {
typescript: true,
nitro: false,
},
});

Logs

✖ Client
  Compiled with some errors in 218.74ms

✔ Server
  Compiled successfully in 197.37ms


 ERROR  Failed to compile with 1 errors                                   friendly-errors 22:57:23


 ERROR  in ./node_modules/cookie-es/dist/index.mjs                        friendly-errors 22:57:23

Module parse failed: Unexpected token (22:12)                             friendly-errors 22:57:23
File was processed with these loaders:
 * ./node_modules/unplugin/dist/webpack/loaders/transform.js
 * ./node_modules/unplugin/dist/webpack/loaders/transform.js
You may need an additional loader to handle the result of these loaders.
|     }
|     const key = str.slice(index, eqIdx).trim();
>     if (opt?.filter && !opt?.filter(key)) {
|       index = endIdx + 1;
|       continue;
                                                                          friendly-errors 22:57:23
 @ ./node_modules/@nuxt/bridge/dist/runtime/composables/cookie.mjs 13:0-45 112:11-16 118:11-20 122:9-18
 @ ./.nuxt/imports.mjs
 @ ./.nuxt/capi.plugin.mjs
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
@wattanx
Copy link
Collaborator

wattanx commented Aug 11, 2024

The following methods can work around this.

export default defineNuxtConfig({
  build: {
    transpile: ['cookie-es']
  },
})

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants