Skip to content

Tests for importing packages using different module strategies (ESM, CJS, TS, TS:node16)

License

Notifications You must be signed in to change notification settings

tuplo/package-test

Repository files navigation

@tuplo/package-test

Imports a package and runs the code using different module strategies.

yarn start

or by tasks

yarn compile
yarn jest
yarn ts

or by individual strategies:

compile:cjs
compile:esm
compile:ts:nodenext
compile:ts:ts-node
compile:ts:tsx

jest:cjs
jest:esm
jest:ts

ts:commonjs
ts:nodenext

CommonJS/ESM Modules

  • imports using require (commonjs)
  • imports using import (esm)

Typescript

  • checks types with moduleResolution: commonjs
  • checks types with moduleResolution: nodenext

Jest

  • tests a commonjs module (native behavior)
  • tests a esm module (following instructions from docs)
  • tests a ts module (with ts-jest)

Usage

  • Install package yarn install @my/package-to-test
  • Edit source files with imports/requires to package and a dummy call to it:
    • src/cjs/index.cjs
    • src/esm/index.mjs
    • src/ts/index.ts
  • Run tests suite yarn start

About

Tests for importing packages using different module strategies (ESM, CJS, TS, TS:node16)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published