Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[nuxt-bridge] Unexpected token 'export' gives critical error with v6 #344

Open
Tragio opened this issue Feb 11, 2022 · 1 comment
Open

Comments

@Tragio
Copy link

Tragio commented Feb 11, 2022

Describe the bug
Using Nuxt Bridge (Vue2), works perfectly in dev and it builds, but if I start my build server and try to access it, I have a critical error.

Screenshot 2022-02-11 at 11 02 57

Reproducible test case
Minimal reproduction:
https://github.com/Tragio/fontawesome-v6-reproduction

Using:

"@fortawesome/fontawesome-svg-core": "^1.3.0",
"@fortawesome/free-solid-svg-icons": "^6.0.0",
"@fortawesome/vue-fontawesome": "^2.0.6",

Thank you for the beautiful work! 🙂

@Tragio
Copy link
Author

Tragio commented Feb 11, 2022

After digging a little bit more, I found that is related to these issues FortAwesome/Font-Awesome#18514 and FortAwesome/Font-Awesome#16439

If I change all packages from .es.js to .mjs, they work perfectly.

If I use "type": "module" I have a critical error.
This file is being treated as an ES module because it has a '.js' file extension and '/Users/tragio/Downloads/fontawesome-reproduction/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

@robmadole could you let us know if is there any ETA to change them?

PS: The workaround at the moment is to add to transpile. https://v3.nuxtjs.org/concepts/esm/#transpiling-libraries
For example:

  build: {
    transpile: [
      'vue-instantsearch',
      'instantsearch.js/es',
      '@fortawesome/fontawesome-svg-core',
      '@fortawesome/free-solid-svg-icons',
      '@fortawesome/free-brands-svg-icons',
    ],
  },

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

No branches or pull requests

2 participants