1.0.14 • Published 1 year ago

@build-script/dual-package-runtime v1.0.14

Weekly downloads
6
License
MIT
Repository
github
Last release
1 year ago

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 imported
  • node -r "@build-script/dual-package-runtime" ./index.js:
    test.cjs has been imported
1.0.14

1 year ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago