1.0.20 • Published 2 years ago

@build-script/typescript-transformer-import-commonjs v1.0.20

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

typescript-transformer-import-commonjs

It will convert things like

import { emptyDir } from 'fs-extra';

Into

import fs_extra_1 from 'fs-extra';
const { emptyDir } = fs_extra_1;

Only if:

  1. path is not relative
  2. package name directly defined in dependencies in package.json
  3. imported package's package.json does not have "type": "module"
  4. not imported with special extensions: .cjs or .mjs or .json

Usage

tsconfig.json: all extra options is optional

{
	"compilerOptions": {
		"plugins": [
			{
				"transform": "@build-script/typescript-transformer-dual-package",
				"specialExtensions": ["cjs", "mjs", "json", "wasm", "cjs.js"], // defaults to cjs,mjs,json
				"ignore": ["some-module"], // do not change import of this package
				"force": ["some-module"], // force change import even it's type is module
				"package.json": "../package.json" // Current package's json file, defaults to find the nearest one
			}
		]
	}
}
1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago