export-tester
TypeScript icon, indicating that this package has built-in type declarations

1.0.13 • Public • Published

Export Tester

Export Tester

This tool can test if your code can be import well in defferent environment.

Environments supported:

  • ts Typescript
  • node-cjs CommonJS running in Node
  • node-esm ES Module running in Node
  • webpack-cjs CommonJS bundled by webpack
  • webpack-esm ES Module bundled by webpack

This test tool had been tested by the tests of this test tool.

Install

npm i export-tester

Import

CommonJS

const tester = require('export-tester');

Typescript

import tester = require('export-tester');

ES Module

import tester from 'export-tester';

Usage

/// <reference path="export-tester/lib/tool.d.ts" />

/// <reference path="some-mod/declaration.d.ts" />
// (If the module tested provide.)

require('export-tester')(
  {
    sign: 'someMod', // The identifier of module imported.
    file: `${__dirname}/lib/index.js`, // Entry file.
    req: ['ts', 'node-esm'], // Test environments.
  },
  {
    logMod() { log(someMod); },
    checkDef() { log(someMod.default); },
    // ...
  },
).then(({ err, detail }) => {
  if (err) console.error(detail);
  process.exit(err);
});

Output:

+-------------------
|  Node ESM
| D:\...\export-tester\lib\test\node.mjs
|
+-"logMod":
| ...
|
+-"checkDef":
| ...
|
+-------------------
|  TS
| Testing cli
| Compiling
| D:\...\export-tester\lib\test\test.js
| D:\...\export-tester\lib\test\test.ts
|
+-"logMod":
| ...
|
+-"checkDef":
| ...
|

Package Sidebar

Install

npm i export-tester

Weekly Downloads

2

Version

1.0.13

License

GPL-3.0-or-later

Unpacked Size

120 kB

Total Files

21

Last publish

Collaborators

  • e0selmy4v