`import` issues on Netlify, SvelteKit and ViteJS
See original GitHub issueI’m getting the following error when building on Netlify:
7:22:56 PM: > Named export 'createWidget' not found. The requested module '@typeform/embed' is a CommonJS module, which may not support all module.exports as named exports.
7:22:56 PM: CommonJS modules can always be imported via the default export, for example using:
7:22:56 PM: import pkg from '@typeform/embed';
7:22:56 PM: const { createWidget } = pkg;
This traces back to:
import { createPopup } from '@typeform/embed';
let showRegistration: boolean = false;
function openRegistrationForm() {
showRegistration = true;
// ID omitted from code example
createPopup('<id>', {
container: document.querySelector('#register')
});
}
The code above works fine in the dev environment but isn’t accepted by Netlify. I haven’t seen it on any other libraries. Unfortunately the solution in the error message doesn’t work locally (although it works in Netlify).
It’s not a permalink, but you can currently see the code context at this branch: https://github.com/bahaistudies/conference/tree/netlify-identity
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
SvelteKit site builds locally, fails with Netlify, rollup import issue
Site: iil.is / iil-is.netlify.app In one of my pages I am importing a BibTeX / .bib file which starts with @inproceedings{...: import pubs...
Read more >When deploying Sveltekit app to Netlify, build breaks with ...
This answer might differ based on which version of SvelteKit you have. Try to add the following to svelte.config.js : import preprocess from ......
Read more >Adapters • Docs • SvelteKit
import adapter from '@sveltejs/adapter-auto'; import adapter from '@sveltejs/adapter-node';. With this, vite build will generate a self-contained Node app ...
Read more >SvelteKit onMount async import weird behaviour on build with ...
I load a quill editor in onMount() and set the plugins and the initial value, it works perfectly in dev. But when I...
Read more >Deploying a Static Site - Vite
Install the Netlify CLI $ npm install -g netlify-cli # Create a new site in ... After your project has been imported and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This library appears to me to be using UMD: https://github.com/Typeform/embed/blob/bc9ddcb1c515617053c9d07480037cfa4a53f714/packages/embed/webpack.config.js#L50
Rather than use UMD and try to serve both browser and server with a single build, the nicer thing to do is typically to output a CJS build specified in
main
and an ESM build specified inmodule
inpackage.json
. Or better yet, just provide an ESM build inmain
and settype: "module"
. You can still provide a UMD build if you have users who include the library via ascript
tag, but it’s generally not preferred for npm packagesHello @benaltair
I think this might be an issue with SvelteKit, please see the discussion here: https://github.com/sveltejs/kit/issues/928
Also related: https://github.com/vitejs/vite/issues/3024