You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

inop

Package Overview
Dependencies
3
Maintainers
0
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

inop

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


Version published
Maintainers
0
Created

Readme

Source

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 The MIT License Copyright (c) 2023-2024 Ivan Zakharchanka

Keywords

FAQs

Package last updated on 04 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc