Comments (6)
BTW. The chain of calls that leads to this code is:
nuxi
(loadKit
)
->
@nuxt/kit
(loadNuxt
)
->
pkg-types
(resolvePackageJSON
)
->
mlly
(resolvePath
)
->
mlly
(_resolve
)
from mlly.
Hmm, there is more issues like that elsewhere. For example in getPackageScopeConfig
which I think comes from internal Node libs. So I think the solution to issues like that is ensure that the base URL ends in slash if it's a directory.
new URL('./', 'file:///project/docs/').href
"file:///project/docs/"
from mlly.
This rabbit hole goes deep.
The first directory that is involved and that doesn't include the trailing slash is the rootDir
one resolved in https://github.com/nuxt/nuxt/blob/184d57bb1923b8bf21a372eabdb67e1241d2023f/packages/nuxi/src/commands/dev.ts#L41.
Forcing trailing slash here fixes this specific issue but creates another.
So it's no longer clear to me what and where should be fixed.
It seems to me like using URI for resolving directory paths is a little brittle since it's not clear whether path is to a directory or a file without doing file IO.
from mlly.
Hi dear @rchl. Thanks for sharing all investigations.
Yes, that's kinda tricky situation. We removed the directory URL workaround but it introduced other regressions in Nuxt 3.
I think first good step would be making a minimal mlly reproduction to test the behavior if you can help 🙏🏼 . We might try to introduce a major version on progressively adopt it within nuxt ecosystem.
from mlly.
I think first good step would be making a minimal mlly reproduction to test the behavior if you can help 🙏🏼
I'm thinking that a unittest for that would be a good reproduction?
So something like https://github.com/unjs/mlly/blob/main/test/fixture/resolve.mjs but I guess this is just a lone file that is not really testing anything?
from mlly.
Yeah. We probably could make an external repo for it. Especially trying node_modules resolution too via an exclude in .gitignore
and then moving it to fixtures (because previous regression happened this way).
from mlly.
Related Issues (20)
- Allow parsing `import type {x, y} from '...'` HOT 2
- Cannot find module 'node:module' HOT 5
- Update for Node.js upstream changes for resolve implementation HOT 2
- Strip query and hash by `sanitizeURIComponent` HOT 5
- `findStaticImports` and `findDynamicImports` do not respect comments
- Analyze Import after function HOT 1
- Non-alphanumeric character as comment in import not detected HOT 1
- Cannot find name 'NodeRequire'
- Named default import HOT 2
- `isValidNodeImport` incorrectly returns `true` for mixed syntax
- interopDefault breaks when combining a default string export with named exports HOT 2
- ESM syntax detection and CJS syntax detection goes through comments
- ensure we don't resolve modules in parent folders HOT 2
- resolvePath's result is different from the module's path. HOT 2
- _findSubpath a strange import error HOT 4
- `findExports` doesn't find multiple variable declaration in sindle export declaration
- Update import-meta-resolve to v4
- Support and respect export conditions for `lookupNodeModuleSubpath`
- Fully switch to AST analyzes
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlly.