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

Failed Build on Netlify #61

Closed
zommerberg opened this issue Jun 16, 2021 · 11 comments
Closed

Failed Build on Netlify #61

zommerberg opened this issue Jun 16, 2021 · 11 comments

Comments

@zommerberg
Copy link

Hello!
From v11 I get the following error when trying to deploy to netlify:

(node:65589) UnhandledPromiseRejectionWarning: file:///.../node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:214
import { createMakeHot } from "svelte-hmr";
         ^^^^^^^^^^^^^
SyntaxError: The requested module 'svelte-hmr' does not provide an export named 'createMakeHot'

Other people reported the same issue with github pages.

Downgrading to v10 manually solves the problem.

@sebastinez
Copy link

Yes I have the same issue on v11 and on v10 it seems there is another issue

import { svelte } from "@sveltejs/vite-plugin-svelte";
         ^^^^^^
SyntaxError: The requested module '@sveltejs/vite-plugin-svelte' does not provide an export named 'svelte'

Any idea to which version we should change?

@bluwy
Copy link
Member

bluwy commented Jun 17, 2021

v11 now includes an ESM bundle and uses named export svelte instead of a default export in v10, but the underlying package svelte-hmr only exports CJS, which I believe caused the underlying createMakeHot error.

I'm not sure how easy it would be to have svelte-hmr provide an ESM bundle, but otherwise we could make a change in vite-plugin-svelte to import with import * as svelteHmr as "svelte-hmr to bypass the issue.

@dominikg
Copy link
Member

thanks for reporting this. The tests with adapter-static still worked so this slipped through :/

I wonder whats going on here though, svelte-hmr shouldn't be part of final build output as it is only used for hmr during dev.
As a workaround you could downgrade to -next.10 and use the default export again ( see https://github.com/sveltejs/vite-plugin-svelte/blob/main/packages/vite-plugin-svelte/CHANGELOG.md#major-changes )

@bluwy
Copy link
Member

bluwy commented Jun 17, 2021

IIRC node had issues in importing named imports of CJS files that do named exports. But I can't reproduce on my side too, could be related to the node version used? A repro would be great @zommerberg

@dominikg I don't think the error shown was part of the build output, but part of the build process when Vite builds and uses the plugin. These questions would be resolved if there were a repro though 😄

@zommerberg
Copy link
Author

@bluwy I can reproduce it only when I try to deploy it. Building it locally doesn't throw an error. The default sveltekit project should be able to reproduce it.

@sebastinez
Copy link

v11 now includes an ESM bundle and uses named export svelte instead of a default export in v10

This solved my issue thank you @bluwy!

@bluwy
Copy link
Member

bluwy commented Jun 17, 2021

@zommerberg Is the netlify deploy log public? Would be nice to see when/how it fails. The log should also show the node version, which I'm guessing it could be that an older node version was used that caused the error, the minimum supported node version for vite-plugin-svelte is v12,

@dominikg
Copy link
Member

yes, please share a full log and a minimal reproduction. I think you're able to select a node version in netlify by adding a .nvmrcfile.

@dominikg
Copy link
Member

according to this sveltejs/kit#1517 (comment) , you have to update your project to match the sveltekit template and add a . node-version file that tells netlify to use a compatible version.

"node": "^12.20 || ^14.13.1 || >= 16"

@zommerberg
Copy link
Author

@dominikg I can confirm that manually setting the node version to v14.17.0 solves the problem.

As far as the old log goes:

11:44:00 PM: $ npm run build
11:44:00 PM: > hamster-app@0.0.1 build /opt/build/repo
11:44:00 PM: > svelte-kit build
11:44:00 PM: (node:1356) ExperimentalWarning: The ESM module loader is experimental.
11:44:00 PM: > The requested module 'svelte-hmr' does not provide an export named 'createMakeHot'
11:44:00 PM: file:///opt/build/repo/node_modules/@sveltejs/vite-plugin-svelte/dist/index.js:214
11:44:00 PM: import { createMakeHot } from "svelte-hmr";
11:44:00 PM:          ^^^^^^^^^^^^^
11:44:00 PM: SyntaxError: The requested module 'svelte-hmr' does not provide an export named 'createMakeHot'
11:44:00 PM:     at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
11:44:00 PM:     at async ModuleJob.run (internal/modules/esm/module_job.js:107:20)
11:44:00 PM:     at async Loader.import (internal/modules/esm/loader.js:179:24)
11:44:00 PM:     at async file:///opt/build/repo/node_modules/@sveltejs/kit/dist/cli.js:645:22

@dominikg
Copy link
Member

thanks

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

No branches or pull requests

4 participants