0.6.10 • Published 22 hours ago

inop v0.6.10

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
22 hours ago

Interoperability

SWC based tool, helps to compile TypeScript code to ESM and CommonJS Interoperable modules.

Build Status NPM version Downloads

Usage

Just run build directory

npx inop src build

Use option -p to adjust package.json with following changes

{
  ...
  "type": "module",
  "main": "build/index.cjs",
  "module": "build/index.js",
  "types": "build/index.d.ts",
  "exports": {
    "require": "./build/index.cjs",
    "import": "./build/index.js"
  },
  "files": [ //list build directory and sources for sourceMap
    "build",
    "src/index.ts"
  ],
  ...
}

Use option -i to ignore specific patterns

npx inop src build -i __tests__ -i __mocks__

As for module declarations and typechecking use the following command, since swc does not support them yet

tsc --declaration --emitDeclarationOnly

Here is the recommended tsconfig.json

{
  "compilerOptions": {
    ...
    "target": "ESNext",
    "module": "NodeNext",
    "declaration": true,
    "esModuleInterop": true,
    "moduleResolution": "NodeNext",
    ...
  },
  ...
}

And jest config jest.config.js

export default {
  ...
  coverageProvider: 'v8',
  extensionsToTreatAsEsm: ['.ts'],
  moduleNameMapper: {
    '^(\\.{1,2}/.*)\\.js$': '$1',
  },
  transform: {
    '^.+\\.ts$': '@swc/jest',
  },
  ...
};

Help

Arguments:
  source                         source directory
  build                          build directory

Options:
  -V, --version                  output the version number
  -m, --match <match>            files match pattern (default: "**/*.ts")
  -s, --swcrc <swcrc>            swcrc path (default: ".swcrc")
  -i, --ignore [ignore...]       ignore patterns
  -p, --package                  adjust package.json according to main property
  --commonjs-ext [commonjs-ext]  file extension of CommonJS files (default: ".cjs")
  --esm-ext [esm-ext]            file extension of ESM files (default: ".js")
  --skip-commonjs                do not generate CommonJS files
  --skip-esm                     do not generate ESM files
  -h, --help                     display help for command

License

License Apache-2.0 Copyright (c) 2023-present Ivan Zakharchanka

0.6.10

22 hours ago

0.6.9

3 days ago

0.6.8

8 days ago

0.6.7

15 days ago

0.6.6

16 days ago

0.6.5

21 days ago

0.6.4

22 days ago

0.6.3

24 days ago

0.6.2

29 days ago

0.6.1

30 days ago

0.6.0

1 month ago

0.5.7

1 month ago

0.5.6

1 month ago

0.5.5

1 month ago

0.5.4

1 month ago

0.5.3

1 month ago

0.5.2

1 month ago

0.5.1

1 month ago

0.5.0

2 months ago

0.4.0

8 months ago

0.4.2

8 months ago

0.3.1

11 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago