Giter Club home page Giter Club logo

Comments (5)

yordis avatar yordis commented on August 16, 2024

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.

yordis avatar yordis commented on August 16, 2024

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.

yordis avatar yordis commented on August 16, 2024

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.

yordis avatar yordis commented on August 16, 2024

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.

sheerlox avatar sheerlox commented on August 16, 2024

Resolved by #81.

The release is available on:

from import-from-esm.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.