Comments (4)
done!
from import-meta-resolve.
Well, this is internals...
from import-meta-resolve.
I kinda figure it out... I guess this issue a bit of an edge cases...
- You need to be using
Node v22
. - You need to be using
pnpm
.
Tested withnpm
andpnpm
. The deprecation warning is not shown withnpm
. I guess its related to howpnpm
treats and resolve transitive dependencies (see point 3, below). - You need to be using a babel presets or plugins that are not directly added as dependency
For example, running:
pnpm add -D @babel/cli @babel/core @babel/preset-env
touch index.js
pnpm exec babel index.js -d out --presets=@babel/preset-env --plugins=@babel/plugin-transform-class-properties
will result in success (kinda) but with a warning.:
(node:279128) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Successfully compiled 1 file with Babel (416ms).
While installing the dependencies using npm
and running with npx
will result in:
npx babel index.js -d out --presets=@babel/preset-env --plugins=@babel/plugin-transform-class-properties
Successfully compiled 1 file with Babel (327ms).
Both commands are using the @babel/plugin-transform-class-properties
plugin, a transitive dependency from @babel/preset-env
. While NPM
can resolve it just fine, pnpm
can't.
But, if we try to use a preset or a plugin that are not installed at all; like @babel/preset-react
for example, both pnpm
and npm
will result in error:
pnpm exec babel index.js -d out --presets=@babel/preset-env,@babel/preset-react --plugins=@babel/plugin-transform-class-properties
(node:280601) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Cannot find package '@babel/preset-react' imported from <REDACTED>/babel-virtual-resolve-base.js
at __node_internal_ (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:224:9)
at new NodeError (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:194:5)
at packageResolve (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:908:9)
at moduleResolve (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:937:20)
at defaultResolve (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1007:15)
at resolve (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1020:12)
at tryImportMetaResolve (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/files/plugins.js:142:45)
at resolveStandardizedNameForImport (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/files/plugins.js:164:19)
at resolveStandardizedName (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/files/plugins.js:173:22)
at loadPreset (<REDACTED>/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/config/files/plugins.js:61:20)
at loadPreset.next (<anonymous>)
...
npx babel index.js -d out --presets=@babel/preset-env,@babel/preset-react --plugins=@babel/plugin-transform-class-properties
(node:280117) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Cannot find package '@babel/preset-react' imported from <REDACTED>/babel-virtual-resolve-base.js
at __node_internal_ (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:224:9)
at new NodeError (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:194:5)
at packageResolve (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:908:9)
at moduleResolve (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:937:20)
at defaultResolve (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1007:15)
at resolve (<REDACTED>/node_modules/@babel/core/lib/vendor/import-meta-resolve.js:1020:12)
at tryImportMetaResolve (<REDACTED>/node_modules/@babel/core/lib/config/files/plugins.js:142:45)
at resolveStandardizedNameForImport (<REDACTED>/node_modules/@babel/core/lib/config/files/plugins.js:164:19)
at resolveStandardizedName (<REDACTED>/node_modules/@babel/core/lib/config/files/plugins.js:173:22)
at loadPreset (<REDACTED>/node_modules/@babel/core/lib/config/files/plugins.js:61:20)
at loadPreset.next (<anonymous>)
...
from import-meta-resolve.
This is happening here on Node 22. You can run the tests and see it.
from import-meta-resolve.
Related Issues (18)
- Issues with loading from ESM, "type": "module", & rollup HOT 2
- Enabling usage of this package in an eslint plugin HOT 8
- Support for TypeScript files HOT 13
- Use module.builtinModules instead of builtins dependency HOT 1
- how to resolve named exports? HOT 5
- 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
- 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
- Incompatible with yarn P'n'P HOT 12
- unexpected `ERR_PACKAGE_PATH_NOT_EXPORTED` thrown HOT 8
- Make this work with yarn berry (aka yarn 2/3/4) HOT 7
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.