-
-
Notifications
You must be signed in to change notification settings - Fork 52
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 from node_modules #165
Comments
Thanks for the detailed report @joas8211! The main issue here is I wrote an internal tool called "gopack" (similar to snowpack) to handle npm modules, but it's not very smart. Currently it only copies npm packages that ship with Our problem in the three.js issue (#164) is similar, but might be slightly different, as it appears to be related to trying to convert this dependency to a component signature based on the error I get in a test repo:
For more details on the thought process of converting named imports to component signatures see: #62 (comment) Lastly, I don't think this is a problem, but also want to note to myself that I simplified gopack not too long ago: ac3a8ed |
I was playing around with this a bit and esbuild does not resolve import paths and appears that's by design. We potentially could write an esbuild plugin using the onResolve callback, just not sure if that offers a huge advantage over the regexp we're currently using in gopack. Maybe a hybrid approach using esbuild to transform node_modules that don't already support esm and gopack to fix the import paths so the browser can read them is the way to go (although I'd prefer to remove gopack completely if someone knows of an existing way to do this without nodejs). Just need to make sure I understand the different module resolver rules for npm. |
From https://the-guild.dev/blog/support-nodejs-esm
Gopack is only accounting for approach 1 above (using |
Hi @joas8211 - Following up on our discussion earlier, I've done some work around NPM imports. For now I've opted to make improvements to the internal "gopack" tool so we can continue using ESM for all dependencies. I haven't done a ton of testing, and NPM module resolution is quite complex, so I'm sure there are some cases that I haven't accounted for. I was able to get a basic D3 example up and running through: Note: you have to upgrade your version of Plenti to v0.4.28 get this to work |
I could not import Netlify CMS from node_modules and recognized that this is a larger issue then just this one case. This has been also noticed in #164 with THREE.js and in #42 generally.
I will use D3.js for more repoducable examples of this issue. The steps to reproduce is as follows.
$ plenti new site plenti-import --bare $ cd plenti-import
layouts/content/index.svelte
as follows:The error that appers in terminal is this:
It seems that Plenti doesn't even try to look for the module in node_modules and copy it to web_modules folder automatically as was somewhat suggested in #42 (comment).
The text was updated successfully, but these errors were encountered: