-
Notifications
You must be signed in to change notification settings - Fork 125
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
import
issues on Netlify, SvelteKit and ViteJS
#288
Comments
Hello @benaltair I think this might be an issue with SvelteKit, please see the discussion here: sveltejs/kit#928 Also related: vitejs/vite#3024 |
Hi @mathio - yes, looks like Vite isn't able to handle the CJS imports well. Is ESM on the horizon for the Typeform library by any chance? |
Upon further inspection, the solution in the error message does indeed work: import pkg from '@typeform/embed';
const { createWidget } = pkg; I'll close this for now, but would love to see ESM support for Typeform. 😊 |
I went through the docs https://nodejs.org/api/esm.html and I think our lib is ECMAScript module. BTW It is completely fine to import the lib and use it like this: import tf from '@typeform/embed';
// ...
tf.createWidget(
// ...
) Could you please provide more details on what you mean by "ESM support" and what are we missing in our lib? |
Hi @mathio, I'm pretty unfamiliar with ES modules to be honest, but from what I understand it has to do with exports - right now only a default export is provided (I believe) and it would be nice to provide separate exports in addition the default, rather than exporting the entire module and then using dot notation. |
Looking closer it does look like this library is using CommonJS modules, not ES modules.
What I would like to request consideration of is to provide an ES module to support more workflows. |
I see there is |
This library appears to me to be using UMD: embed/packages/embed/webpack.config.js Line 50 in bc9ddcb
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 |
I just tried reproducing this issue with a minimal Sveltekit app and was unable to, could you provide a reproducible example? |
We were unable to reproduce this. If you still experience this please feel free to reopen this with additional information. |
I'm getting the following error when building on Netlify:
This traces back to:
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
The text was updated successfully, but these errors were encountered: