1.0.14 • Published 3 years ago
@build-script/dual-package-runtime v1.0.14
dual package runtime
When you run require("./some/file"), it will try "some/file.js" first, and throw if not found.
But with this package, it will try "some/file.cjs" first, then "some/file.js", if both not found, throw.
Note: this will not effect any import, only affect require()(include transpiled ones).
Usage:
import "@build-script/dual-package-runtime";
import { xxx } from "./some-my-files";Or
require("@build-script/dual-package-runtime");
const { xxx } = require("./some-my-files");Example
index.js:
require('./test');test.cjs:
console.log('test.cjs has been imported');test.js:
console.log('test.js has been imported');node ./index.js:
test.js has been importednode -r "@build-script/dual-package-runtime" ./index.js:
test.cjs has been imported