You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the latest version of Snowpack and all plugins.
What package manager are you using?
npm
What operating system are you using?
macOS (Monterey 12.3)
Describe the bug
When you try to import an index.ts file from a directory with a dot (.) in its name, Snowpack won't resolve to the index file, instead it will fail trying to import the directory as a file (with a .proxy.js postfix).
With zero knowledge of how Snowpack works under the hood, from the behaviour I assume, that when a you import a path and the last part of the path contains a dot, Snowpack assumes that it's a file name with an extension. Thus trying to import a non-existing file (and adding the .proxy.js postfix, because it doesn't know the non-existing 'extension'). If this is indeed the case, it should be fixable by checking if the path is file or directory, and if it is a directory, checking if it contains an index file and importing it instead.
Snowpack will fail with error Error: Not Found (/some.directory) (if running build), or with error GET http://localhost:8090/some.directory.proxy.js net::ERR_ABORTED 404 (Not Found) (if running start) The expected behaviour is that Snowpack should have imported the index file in the directory, instead of treating the directory itself as a file.
If you'd rather write the bug yourself (instead of using the minimal reproducible example repo):
Initialise a new, bare bone, empty snowpack project
In your source directory, create a new directory that contains a dot in its name (eg. some.directory)
In this new directory, create an index file and export something/anything (eg. echo "\nexport const someData = {\nfoo: \"bar\"\n}" > some.directory/index.ts)
Then try to import this directory from another file - don't explicitly specify the index file (ie. import { someData } from './some.directory', NOT import { someData } from './some.directory/index')
Quick checklist
What package manager are you using?
npm
What operating system are you using?
macOS (Monterey 12.3)
Describe the bug
When you try to import an index.ts file from a directory with a dot (.) in its name, Snowpack won't resolve to the index file, instead it will fail trying to import the directory as a file (with a
.proxy.js
postfix).With zero knowledge of how Snowpack works under the hood, from the behaviour I assume, that when a you import a path and the last part of the path contains a dot, Snowpack assumes that it's a file name with an extension. Thus trying to import a non-existing file (and adding the
.proxy.js
postfix, because it doesn't know the non-existing 'extension'). If this is indeed the case, it should be fixable by checking if the path is file or directory, and if it is a directory, checking if it contains an index file and importing it instead.Steps to reproduce
git clone https://github.com/patrik-simunic-cz/bug-directory-dot-snowpack.git
cd bug-directory-dot-snowpack
npm start
ornpm run build
Error: Not Found (/some.directory)
(if runningbuild
), or with errorGET http://localhost:8090/some.directory.proxy.js net::ERR_ABORTED 404 (Not Found)
(if runningstart
)The expected behaviour is that Snowpack should have imported the index file in the directory, instead of treating the directory itself as a file.
If you'd rather write the bug yourself (instead of using the minimal reproducible example repo):
some.directory
)echo "\nexport const someData = {\nfoo: \"bar\"\n}" > some.directory/index.ts
)import { someData } from './some.directory'
, NOTimport { someData } from './some.directory/index'
)Link to minimal reproducible example (optional)
https://github.com/patrik-simunic-cz/bug-directory-dot-snowpack.git
The text was updated successfully, but these errors were encountered: