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.js requires transpilation to use in v2.1.2 #125

Closed
nwittwer opened this issue Jun 18, 2021 · 2 comments
Closed

Nuxt.js requires transpilation to use in v2.1.2 #125

nwittwer opened this issue Jun 18, 2021 · 2 comments
Labels
Incompatibility Something is incompatible / move to newer version question Further information is requested wontfix This will not be worked on

Comments

@nwittwer
Copy link

nwittwer commented Jun 18, 2021

What is the problem?

After upgrading from 2.0.3 to 2.1.2, I am running into an error about the .mjs library source file needing a loader.

What is the current behavior?

Usage: import SelectionArea from '@simonwep/selection-js'

ERROR in ./node_modules/@simonwep/selection-js/lib/selection.min.mjs 2:1784
Module parse failed: Unexpected token (2:1784)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

Please provide the steps to reproduce and create a JSFiddle.

https://codesandbox.io/s/naughty-carson-7t83s?file=/nuxt.config.js

  1. Open demo
  2. Notice error
  3. Enable lines 4-6 in nuxt.config.js, as below:
{
  build: {
    transpile: ['@simonwep/selection-js'],
  }
}
  1. Restart server or reload the CodeSandbox demo
  2. The error goes away

What is the expected behavior?

I expected this library to work out-of-the-box as it did in 2.0.3. If not, maybe the docs should mention how transpilation/Babel may be required? Or is this more of an issue from Nuxt's side?

Your environment:

Version 2.1.2
Browser:  Chrome
OS:  Windows 10
Node v14.15.3
Nuxt v2.15.7
Package manager: Yarn
@simonwep
Copy link
Owner

simonwep commented Jun 18, 2021

I'd rather say that this is a nuxt "issue". ES Modules are the way to go and "old" tools such as nuxt will have to catch up at some point (check out vite as comparison).

I'll add this to a FAQ section though. I'll document this in v3. But the way you solved it is the right way in this case :)

@simonwep simonwep added Incompatibility Something is incompatible / move to newer version question Further information is requested wontfix This will not be worked on labels Jun 18, 2021
@simonwep
Copy link
Owner

I'll close this for now as I will favor modern builds :) Maybe I'll think of something in v3, but for now I'll keep it that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Incompatibility Something is incompatible / move to newer version question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants