GithubHelp home page GithubHelp logo

Comments (5)

johnnyreilly avatar johnnyreilly commented on May 5, 2024 4

So it turns out this is catered for; just not really documented. I've written a blog post about it here. The TL;DR; show me an example is:

const node = require("enhanced-resolve/lib/node");

function makeSyncResolver(options) {
    return node.create.sync(options.resolve);
}

const resolveSync = makeSyncResolver(loader.options);

const resolvedFileName = resolveSync(
    undefined,
    'C:\source\ts-loader\.test\babel-issue92',
    './submodule/submodule'
);

// resolvedFileName: C:\source\ts-loader\.test\babel-issue92\submodule\submodule.tsx

from enhanced-resolve.

niieani avatar niieani commented on May 5, 2024

If possible, it would be useful for my webpack dependency suite too. Would be especially useful if the sync resolve function could return cached values from the async resolve in case the FS is async in the calling context.

from enhanced-resolve.

niieani avatar niieani commented on May 5, 2024

@johnnyreilly Would this work with a custom fs though?

from enhanced-resolve.

johnnyreilly avatar johnnyreilly commented on May 5, 2024

I haven't tried - have a go!

from enhanced-resolve.

mikesherov avatar mikesherov commented on May 5, 2024

@johnnyreilly please feel free to open a PR to the documentation of this repo (the README) describe this sync resolver. In the meantime, I'm going to consider this issue closed. Thanks!

from enhanced-resolve.

Related Issues (20)

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.