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

Fix format assumption when resolving module dependencies #10878

Merged
merged 2 commits into from
Mar 27, 2023

Conversation

RobinMalfait
Copy link
Contributor

This PR fixes an assumption when resolving the module dependencies given a path.

When resolving dependencies given a path, we are only interested relative files from the current file. We are not interested in the dependencies that are listed in your package.json and thus in your node_modules folder.

We made the assumption that your imports have at least 3 characters. This sort of makes sense because there will be a ., then the OS separator like / and than a file name. E.g.: ./a is the minimal amount of characters.

This makes sense for import statements, but in the case of require, it is totally valid to write require('.'). This will require the current index.{js,ts,mjs,cjs,...} in the current directory.

Before this change, having a require('.') wouldn't crash, but the dependency would not be marked as a module dependencies and therefore we won't listen for file changes for that dependency.

When resolving dependencies given a path, we are only interested
relative files from the current file. We are not interested in the
dependencies that are listed in your `package.json` and thus in your
`node_modules` folder.

We made the assumption that your imports have at least 3 characters.
This sort of makes sense because there will be a `.`, then the OS
separator like `/` and than a file name. E.g.: `./a` is the minimal
amount of characters.

This makes sense for `import` statements, but in the case of `require`,
it is totally valid to write `require('.')`. This will require the
current `index.{js,ts,mjs,cjs,...}` in the current directory.

Before this change, having a `require('.')` wouldn't crash, but the
dependency would not be marked as a module dependencies and therefore we
won't listen for file changes for that dependency.
@RobinMalfait RobinMalfait merged commit 55aa403 into master Mar 27, 2023
@RobinMalfait RobinMalfait deleted the fix/module-dependency-assumption branch March 27, 2023 17:41
bradlc added a commit to tailwindlabs/tailwindcss-intellisense that referenced this pull request Mar 27, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant