@vanillaes/esmtk
v1.1.1
Published
ES Module Toolkit
Maintainers
Readme
Commands
- init - Create a package.json file for ECMAScript module development
- test - Run tests (using Tape-ES)
- lint - Lint the source code (using Lint-ES)
- type - Type check the JSDoc typings (using Typescript)
- bundle - Bundle the source code to an ECMAScript module (using ESBuild)
- minify - Bundle and Minify the source code to an ECMAScript module (using ESBuild)
- commonjs - Bundle the source code to a CommonJS module (using ESBuild)
- typings - Generate Type Declarations (.d.ts) from JSDoc (using Typescript)
- clean - Clean up build artifacts
- preview - Preview the package contents included during
npm publish - cp - A cross-platform clone of the
cpcommand in Linux - rm - A cross-platform clone of the
rmcommand in Linux
Init
Create a package.json file for ECMAScript module development
Arguments
esmtk init [...options]
--scripts- Include ESMTK scripts
Usage
# init package.json
npx @vanillaes/esmtk init
# init package.json (including ESMTK scripts)
npx @vanillaes/esmtk init --scriptsTest
Run tests (using Tape-ES)
Arguments
esmtk test [...options] [glob]
[glob]- the glob used to locate test files (default:**/*.spec.js)--ignore- the ignore matcher pattern (default**/node_modules/**)--cwd- the current working directory (defaultprocess.cwd())--watch- watch for changes to the tests
Usage
# run the tests
npx @vanillaes/esmtk test
# run the tests (using a different naming scheme)
npx @vanillaes/esmtk test **/*.test.js
# run the tests (ignore tests)
npx @vanillaes/esmtk test **/*.test.js --ignore **/node_modules/**,src/rm.spec.js
# run the tests (change the current working directory)
npx @vanillaes/esmtk test **/*.test.js --cwd src/
# run the tests (watch for changes)
npx @vanillaes/esmtk test --watchLint
Lint the source code (using Lint-ES)
Arguments
esmtk lint [...options]
--fix- automatically fix problems
Usage
# lint the sources
esmtk lint
# lint the sources and attempt to automatally fix the issues
esmtk --fix lintType
Type check the JSDoc typings (using Typescript)
Arguments
esmtk type [...options] [entry]
[entry]- the entry-point for the source--strict- enable 'strict mode' type checks
Usage
# type check the sources
esmtk type index.js
# type check the sources (with 'strict mode' enabled)
esmtk type --strict index.jsNode: Due to Typescript limitations, inline JSDoc typings will be ignored if typings (ie *.d.ts files) exist.
Bundle
Bundle the source code to an ECMAScript module (using ESBuild)
Arguments
esmtk bundle [...options] [input] [output]
[input]- the input source file path[output]- the output bundle file path--platform=<platform>- target a specific platform (ex 'node')
Usage
# bundle ESM source -> ESM bundle
esmtk bundle src/sample.js bundle.js
# bundle ESM source -> ESM bundle (includes Node-specific bindings)
esmtk bundle --platform=node src/sample.js bundle.jsMinify
Bundle and Minify the source code to an ECMAScript module (using ESBuild)
Arguments
esmtk minify [...options] [input] [output]
[input]- the input source file path[output]- the output bundle file path--platform=<platform>- target a specific platform (ex 'node')--sourcemap- generate a source map for the minified bundle
Usage
# bundle ESM source -> minified ESM bundle
esmtk minify src/sample.js bundle.min.js
# bundle ESM source -> minified ESM bundle (includes Node-specific bindings)
esmtk minify --platform=node src/sample.js bundle.min.js
# bundle ESM source -> minified ESM bundle (output a sourcemap)
esmtk minify --sourcemap src/sample.js bundle.min.jsCommonJS
Bundle the source code to a CommonJS module (using ESBuild)
Arguments
esmtk commonjs [...options] [input] [output]
[input]- the input source file path[output]- the output bundle file path--platform=<platform>- target a specific platform (ex 'node')
Usage
# bundle ESM source -> CommonJS bundle
esmtk commonjs src/sample.js bundle.cjs
# bundle ESM source -> CommonJS bundle (includes Node-specific bindings)
esmtk commonjs --platform=node src/sample.js bundle.cjsTypings
Generate Type Declarations (.d.ts) from JSDoc (using Typescript)
Arguments
esmtk typings [entry]
[entry]- the entry-point for the source
Usage
# generate .d.ts files for all linked source files
esmtk typings index.jsClean
Clean up build artifacts
Arguments
esmtk clean [...options] [cwd]
[cwd]- the current working directory (default:process.cwd())--bundle- Clean bundled build artifacts (default:**/*.esm.js)--minify- Clean minified build artifacts (default:**/*.min.js)--typings- Clean typing artifacts (default:**/*.d.ts)--custom- Clean based on a user-defined pattern
Usage
# clean all build artifacts
esmtk clean --bundle --minify --typings
# override default extension
esmtk clean --bundle *.mjs
# define your own pattern
esmtk clean --custom *.scss.cssNode: The clean command automatically ignores the contents of node_modules/
Preview
Preview the package contents included during npm publish
Arguments
esmtk preview [...options]
--cwd- the current working directory
Usage
# preview the package contents
esmtk preview
# preview the package contents (from another directory)
esmtk preview --cwd some/other/dirCP
A cross-platform clone of the cp command in Linux
Arguments
esmtk cp [...options] [source...] [destination]
[source(s)...]- the source file(s)/glob(s)[destination]- the destination file/directory-r, --recursive- copy files/directories recursively
Usage
# copy one file
esmtk cp file1.txt dest/file1.txt
# copy multiple files
esmtk cp file1.txt file2.txt file3.txt dest/
# copy files that match a glob
esmtk cp *.txt dest/
# copy files that match multiple globs
esmtk cp *.txt *.js *.ts dest/
# recursively copy files from one directory to another
esmtk cp -r src/ dest/RM
A cross-platform clone of the rm command in Linux
Arguments
esmtk rm [...options] [path(s)...]
[path(s)...]- the source file(s)/glob(s)-r, --recursive- remove directory recursively
Usage
# remove one file
esmtk rm file1.txt
# remove multiple files
esmtk rm file1.txt file3.txt file3.txt
# remove files that match a glob
esmtk rm *.txt
# remove files that match miltiple globs
esmtk rm *.txt *.js *.ts
# recursively remove a
esmtk rm -r src/