-
-
Notifications
You must be signed in to change notification settings - Fork 432
'import' and 'export' may only appear at the top level #1151
Comments
Also seeing this |
@matt3224 My current hack is to build and run |
I just rolled plugin-commonjs back to 11.0.2 and removed the ^ for now, will try again on the next version |
@matt3224 Excellent hack... Thanks 👍 |
Same issue here |
I'll link to the issue up on rollup/plugins rollup/plugins#304 |
Just encountered same error. Everything gets fixed if
this is happening due to
|
As mentioned above, going to node_modules/sapper/sapper-dev-client.js and changing export function connect(port) {
if (source || !window.EventSource) return; To module.exports.connect = function connect(port) {
if (source || !window.EventSource) return; Fixes the issue locally, live reload is working after that. |
Also seeing this issue in a clean install of Sapper. |
Anyone trying Sapper is going to have a bad time rn. Until the roll up plugin is fixed, the fix posted here: sveltejs/sapper#1151 is a good temp patch.
Anyone trying Sapper is going to have a bad time rn. Until the roll up plugin is fixed, the fix posted here: sveltejs/sapper#1151 is a good temp patch.
For what it's worth, this error happens to me only on Node.js 10+ (10.18.1 specifically). Same version of sapper running on 8.13.0 does not have this error. |
From local testing, this appears to be fixed by rollup/plugins#355 and I am eagerly awaiting its merge, and will update sapper-template once the update is released and I've given it another test. |
Also relevant: sveltejs/sapper-template#218 |
PostCSS minor version bump Svelte minor version bump Rollup major update to version ^2.7 Note: `@rollup/plugin-commonjs` was not updated due to issue with sapper: sveltejs/sapper#1151
You can use the following NPM scripts until this gets fixed upstream. "dev": "npm run dev:sapper:fix && sapper dev",
"dev:sapper:fix": "run-s dev:sapper:fix:one dev:sapper:fix:two",
"dev:sapper:fix:one": "sed -i 's/export function connect/function connect/g' ./node_modules/sapper/sapper-dev-client.js",
"dev:sapper:fix:two": "grep -qF 'exports = {connect}' ./node_modules/sapper/sapper-dev-client.js || echo 'exports = {connect}' >> ./node_modules/sapper/sapper-dev-client.js", |
If you're running the above scripts on MacOS, you'll need to change the
I also needed to change the And here it is in place for copy pasta goodness:
|
This is resolved with |
PostCSS minor version bump Svelte minor version bump Rollup major update to version ^2.7 Note: `@rollup/plugin-commonjs` was not updated due to issue with sapper: sveltejs/sapper#1151
Based on solution described here: sveltejs/sapper#1151 (comment)
how do i upgrade? I get an error when changing to |
Describe the bug
On fresh Sapper project , running
sapper dev
results into an unknown error'import' and 'export' may only appear at the top level
Running
sapper build
proceeds with no failLogs
To Reproduce
git clone https://github.com/sveltejs/sapper-template-rollup.git
yarn
ornpm install
yarn run dev
ornpm run dev
Expected behavior
Application runs with no problems
Stacktraces
If you have a stack trace to include, we recommend putting inside a
<details>
block for the sake of the thread's readability:Stack trace
Information about your Sapper Installation:
Your browser and the version: not applicable
Your operating system: MacOS 10.15.4
Your hosting environment: Local
Sapper version
^0.27.0
and^0.27.12
Svelte version
^3.0.0
and^3.20.1
dynamic application.
Rollup
Severity
Medium
Blocking usage of Sapper as local development can not run
Additional context
sapper build works
The text was updated successfully, but these errors were encountered: