sindresorhus / import-fresh

Import a module while bypassing the cache
MIT License
283 stars 24 forks source link

Browserify support #10

Closed kumavis closed 5 years ago

kumavis commented 5 years ago

Does not work with browserify. Underlying issue is here https://github.com/sindresorhus/resolve-from/issues/10

Some context on how that gets called:

resolveFrom is called with these values

resolveFrom(path.dirname(callerPath()), moduleId)
resolveFrom(path.dirname(undefined), moduleId)
resolveFrom(".", "./foo")

resolveFileName is called with these values

const resolveFileName = () => Module._resolveFilename(moduleId, {
  id: fromFile,
  filename: fromFile,
  paths: Module._nodeModulePaths(fromDir)
});
const resolveFileName = () => Module._resolveFilename("./foo", {
  id: "/http:/localhost:9966/noop.js",
  filename: "/http:/localhost:9966/noop.js",
  paths: Module._nodeModulePaths("/http:/localhost:9966")
});
sindresorhus commented 5 years ago

Same answer as https://github.com/sindresorhus/resolve-from/issues/10#issuecomment-447524553.