Comments (5)
From https://yarnpkg.com/advanced/pnpapi:
Finally, it can be noted that findPnpApi isn't actually needed in most cases and we can do the same with just createRequire thanks to its resolve function:
const {createRequire} = require(`module`);
// We'll be able to inspect the dependencies of the module passed as first argument
const targetModule = process.argv[2];
const targetRequire = createRequire(targetModule);
const resolved = targetRequire.resolve(`eslint`);
const instance = targetRequire(resolved); // <-- still important
from import-from-esm.
I found the issue,
function tryResolve(moduleId, baseURL) {
debug(`Trying to resolve '${moduleId}' from '${baseURL.href}'`);
try {
// THIS WORKS
return import.meta.resolve(moduleId, baseURL.href);
// THE PROBLEM
// return moduleResolve(moduleId, baseURL, new Set(['node', 'import']));
} catch (error) {
debug(`Failed to resolve '${moduleId}' from '${baseURL.href}': ${String(error)}`);
}
}
from import-from-esm.
I created #81 to open the conversation, that solves the issue but I am not sure why it wasn't done that way to begin with, so I am gonna way to find more context about it
from import-from-esm.
Related to wooorm/import-meta-resolve#10
I am a bit confused, but the fact that native import.meta.resolve
does work but the package does it, I feel the package is at fault here.
https://yarnpkg.com/getting-started/qa#does-yarn-support-esm
from import-from-esm.
Resolved by #81.
The release is available on:
from import-from-esm.
Related Issues (12)
- Goals & purpose of this library HOT 1
- Dependency Dashboard
- Error on npm install HOT 5
- test: split fuzz testing from main test workflow
- node_modules/import-from-esm/index"' has no default export HOT 2
- feat: support loading packages' JSON index and main HOT 1
- test: check importFrom outcome against require's in e2e and fuzz tests
- `exports` are not resolved correctly HOT 1
- import-from-esm abstracts CommonJS/ESM file extension errors
- Module subpath doesn't resolve HOT 5
- MODULE_NOT_FOUND HOT 1
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-from-esm.