mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Fix format assumption when resolving module dependencies (#10878)
* fix assumption when resolving dependencies
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.
* update changelog
This commit is contained in:
parent
8e85a865da
commit
55aa4035f5
@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Sort class lists deterministically for Prettier plugin ([#10672](https://github.com/tailwindlabs/tailwindcss/pull/10672))
|
||||
- Ensure CLI builds have a non-zero exit code on failure ([#10703](https://github.com/tailwindlabs/tailwindcss/pull/10703))
|
||||
- Ensure module dependencies for value `null`, is an empty `Set` ([#10877](https://github.com/tailwindlabs/tailwindcss/pull/10877))
|
||||
- Fix format assumption when resolving module dependencies ([#10878](https://github.com/tailwindlabs/tailwindcss/pull/10878))
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ function* _getModuleDependencies(filename, base, seen, ext = path.extname(filena
|
||||
for (let match of [
|
||||
...contents.matchAll(/import[\s\S]*?['"](.{3,}?)['"]/gi),
|
||||
...contents.matchAll(/import[\s\S]*from[\s\S]*?['"](.{3,}?)['"]/gi),
|
||||
...contents.matchAll(/require\(['"`](.{3,})['"`]\)/gi),
|
||||
...contents.matchAll(/require\(['"`](.+)['"`]\)/gi),
|
||||
]) {
|
||||
// Bail out if it's not a relative file
|
||||
if (!match[1].startsWith('.')) continue
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user