Skip to content
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

🐛 BUG: Importing index from directory with dot in its name #3895

Open
1 task done
patrik-simunic-cz opened this issue Mar 27, 2022 · 0 comments
Open
1 task done

Comments

@patrik-simunic-cz
Copy link

patrik-simunic-cz commented Mar 27, 2022

Quick checklist

  • 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.

Steps to reproduce

  1. git clone https://github.com/patrik-simunic-cz/bug-directory-dot-snowpack.git
  2. cd bug-directory-dot-snowpack
  3. npm start or npm run build
  4. 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):

  1. Initialise a new, bare bone, empty snowpack project
  2. In your source directory, create a new directory that contains a dot in its name (eg. some.directory)
  3. In this new directory, create an index file and export something/anything (eg. echo "\nexport const someData = {\nfoo: \"bar\"\n}" > some.directory/index.ts)
  4. 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')
  5. Build or serve the project

Link to minimal reproducible example (optional)

https://github.com/patrik-simunic-cz/bug-directory-dot-snowpack.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant