Replies: 4 comments 3 replies
-
@Rich-Harris Not sure if |
Beta Was this translation helpful? Give feedback.
-
We do try and discourage aliasing in general because it’s an additional level abstraction away from the code that runs in browser. A goal of Snowpack is to reduce the mental overhead that’s currently required in what you write vs what ships. That said, we do support import aliases in your Let me know if this solves your issue!
For performance reasons, we do watch all mounted directories in your project for HMR, but we do not monitor |
Beta Was this translation helpful? Give feedback.
-
The magic of Snowpack is still in esinstall, which is our ability to upconvert packages from Common.js to ESM, saving them into a new ESM-only But esinstall is run at the top-level, so it doesn't support a node_modules directory nested in source like src/foo/node_modules/*. We'd like to avoid supporting this if at all possible, since it's a bit antithetical to how that works by creating a single, final install directory (ex: where does the nested dependency end up in the final web_modules dir? what if two nested names conflict? etc). Since nested node_modules in source are usually just used for the convenience of a simpler import, our official project recommendation is to use Snowpack aliases to achieve this convenience instead. |
Beta Was this translation helpful? Give feedback.
-
I am going through the same struggles where we have a react ui toolkit that imports .module.css files and snowpack is looking for a css.proxy.js at the location of the component being imported. this means i'll have to create a component wrapper for each component just to re-import the css into the snowpack project. |
Beta Was this translation helpful? Give feedback.
-
Sapper uses
src/node_modules/*
for generated files as they can be imported without long relative paths. Given this pattern many Svelte/Sapper users have begun to use this pattern to store their own components etc to avoid relative imports or setup aliases in their entire tool stack (see sveltejs/sapper#551).Snowpack seems unable to resolve modules within
src/node_modules/*
. I tried by:Then add to
.gitignore
:.build build web_modules node_modules +!src/node_modules
Then add
src/node_modules/@components/Test.svelte
:and try importing it in
src/App.svelte
:I get error:
Not sure if I am doing something wrong here or if Snowpack resolution doesn't support this type of usage.
Relative importing works as expected (doing this 👇 ):
<script> + import Test from "./node_modules/@components/Test.svelte";
EDIT: I discovered HMR doesn't work on the relative import
./node_modules/@components/Test.svelte
where it does on a component not undersrc/node_modules/*
.Beta Was this translation helpful? Give feedback.
All reactions