sveltejs / svelte-loader

Webpack loader for svelte components.
MIT License
597 stars 72 forks source link

Error in release 3.1.1 (Module parse failed: 'import' and 'export' may only appear at the top level (138:339)) #178

Closed Wellington3010 closed 3 years ago

Wellington3010 commented 3 years ago

Errror in release 3.1.1

Using version 3.1.1 noticed that the following error message is displayed:

Screenshot from 2021-04-25 21-06-11

Changing version in package.json for 2.13.6, the error message is not displayed and project works.

Analyzing the loader code in version 3.1.1 I found that in the hot-api.js file we have an export that is not at the top-level of the file, contrary to the JS strict mode ES6 rule. I believe this could be the mistake.

Screenshot from 2021-04-25 21-12-30

halfnelson commented 3 years ago

There is a fix for this in v0.14 and v0.13 of svelte-hmr (https://github.com/rixo/svelte-hmr/pull/31)

I am submitting a PR to bump versions of svelte-hmr (there were some API interface changes that needed to be reflected in the loader)

Wellington3010 commented 3 years ago

Thanks @halfnelson for share information about this update.

silverdr commented 3 years ago

What is currently the "safe" combination of svelte and svelte-loader for webpack4, that does not exhibit this issue?

non25 commented 3 years ago

Ways you can solve this currently:

There's no safe combination, because svelte-hmr broke in minor version (0.12.4), and package.json indicates that we can safely install any 0.12.* which is not the case.

Perhaps you can just install master with @halfnelson commit, because if we don't ask @Conduitry for a release in svelte discord chat, nothing will be released.

npm install -D sveltejs/svelte-loader
# or if using yarn 2
yarn add -D svelte-loader@sveltejs/svelte-loader
benmccann commented 3 years ago

3.1.2 has been released, so I think this is fixed now

Wellington3010 commented 3 years ago

3.1.2 has been released, so I think this is fixed now

Thank´s @benmccann.