sveltejs/svelte-loader

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

Wellington3010 opened this issue · 6 comments

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

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)

Thanks @halfnelson for share information about this update.

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

non25 commented

Ways you can solve this currently:

  • pin minimum acorn version to v7 through resolutions (yarn) or overrides | package (npm)
  • pin svelte-hmr version to something that has worked before, e.g. 0.12.3 through the same mechanisms
  • disable HMR

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

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

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

Thank´s @benmccann.