1.0.13 • Published 1 year ago

export-tester v1.0.13

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
1 year ago

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":
| ...
|