Comments (12)
This isn't a PnP issue, more a missing import-meta-resolve feature (standard Node.js loader support), see #10 (comment)
from import-meta-resolve.
What do you mean by
So using Yarn like this means you can’t use node
There is yarn node
Is that normal for Yarn users? That they can’t call commitlint? They have to wrap it in yarn commitlint?
When use yarn, the user must use yarn commitlint
, like npx commitlint
, there is no yarn global
binaries anymore.
Use import.meta.resolve. Don‘t use this package.
I'd love to, but we're still targeting on Node < 20, and the second parameter is still experimental.
There are use cases when you do or don’t want loaders. I like not having to load all that code to support loaders.
Understand, I'm fine with not supporting loaders(or yarn P'n'P actually) personally.
from import-meta-resolve.
I think it’s interesting, the Yarn PnP thing. But it intentionally does lots of things differently. As you show, it has to wrap CLIs and node
itself. So it’s not going to work with several tools.
As for supporting loaders, I think it would be a lot of work. Also to maintain. I don’t think anyone is interested in doing that work. See #10 (comment).
from import-meta-resolve.
It can’t work, see #10.
from import-meta-resolve.
Yeah, I looked through that issue, and hope the yarn berry team can help.
cc @arcanis @merceyz @paul-soporan @larixer
from import-meta-resolve.
I think we'd better discuss in this new issue instead of the closed one.
So I quoted @arcanis's comment here.
As I understand it (I backported recent changes just now), loaders are implemented above
resolve
: nodejs/node@3ebe753
/lib/internal/modules/esm/loader.js.It's the other way around -
import.meta.resolve
must go through loaders. If it wasn't, callingimport(import.meta.resolve(...))
wouldn't work, which would be unacceptable. You can easily check it:import {register} from 'module'; // export async function resolve() { // return {shortCircuit: true, url: 'file:///lol'}; // } register('data:application/javascript;charset=utf-8,export%20async%20function%20resolve%28%29%20%7B%0D%0A%20%20return%20%7BshortCircuit%3A%20true%2C%20url%3A%20%27file%3A%2F%2F%2Flol%27%7D%3B%0D%0A%7D'); console.log(import.meta.resolve('foo'));Prints
file:///hello
In other words,
import-meta-resolve
should implement loader support to be on parity withimport.meta.resolve
, this isn't an issue with PnP itself.
from import-meta-resolve.
It's the other way around - import.meta.resolve must go through loaders
Then where is the code in Node that does that?
I know that it’s still done by the function at
import.meta.resolve
. But it’s not in the code Node uses to resolve things. Similar to howimport.meta.url
can’t be polyfilled.In other words, import-meta-resolve should implement loader support to be on parity with import.meta.resolve
Where is the API in Node to find which loaders are currently turned on? I don’t think it exists. I don’t think this can be done.
from import-meta-resolve.
Joun, what you are asking for is that people have to specify --loader some-yarn-loader
to your commit-lint CLI.
Do you really want that?
from import-meta-resolve.
@wooorm I don't think that's the solution? yarn
will call its own .pnp.loader.mjs
automatically without user action.
from import-meta-resolve.
Yes that’s a loader. Someone has to use it?
If you want this package to support loaders like Node does, then it would mean someone has to do commitlint --loader .pnp.loader.mjs
?
from import-meta-resolve.
No, the user don't need to do like that, he/she would only need to run yarn commitlint
, no need to specific --loader
option. What means yarn
wraps --loader .pnp.loader.mjs
for the user automatically.
from import-meta-resolve.
It sort of does that. It can’t exactly, because your CLI calls Node: https://github.com/conventional-changelog/commitlint/blob/87b1d36d23005b9c1d010ff6a49d1de7f4888cfe/%40commitlint/cli/cli.js.
Yarn is injecting environment variables.
So using Yarn like this means you can’t use node
. Jeez.
Is that normal for Yarn users? That they can’t call commitlint
? They have to wrap it in yarn commitlint
?
Use import.meta.resolve
. Don‘t use this package. The readme says that no loaders (and no env variables) are supported: https://github.com/wooorm/import-meta-resolve#differences-to-node.
import.meta.resolve
is stable now. Loaders are incredibly complex. You are free to try it, I think it would be another project the size of this one.
There are use cases when you do or don’t want loaders. I like not having to load all that code to support loaders.
from import-meta-resolve.
Related Issues (18)
- Issues with loading from ESM, "type": "module", & rollup HOT 2
- Yarn PnP compatibility? HOT 18
- Want help on maintenance? HOT 4
- Circular dependency in lib/get-format.js HOT 1
- `import.meta.resolve` is now defined to be _sync_ HOT 1
- Possible to use worker threads and execArgv? HOT 14
- exporting the `packageResolve` function HOT 2
- Support for resolving modules from folder paths HOT 8
- Enabling usage of this package in an eslint plugin HOT 8
- First item is always resolved when export map target is Array (even if non-existent) HOT 8
- Resolve fails on MacOS and Windows, works on linux HOT 7
- unexpected `ERR_PACKAGE_PATH_NOT_EXPORTED` thrown HOT 8
- Make this work with yarn berry (aka yarn 2/3/4) HOT 7
- [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated in Node v22.0.0 HOT 4
- Support for TypeScript files HOT 13
- Use module.builtinModules instead of builtins dependency HOT 1
- how to resolve named exports? HOT 5
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 import-meta-resolve.