1.0.14 • Published 3 years ago

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

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years 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

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago