serpack v0.1.19
serpack
Serpack is a JavaScript/TypeScript tool for application development, powered by swc.
$ npx serpack ./src/awesome-app.ts # run script
Serpack is optimized for high-speed bundling and execution of TypeScript files, leveraging swc as a transformer and oxc as a resolver for enhanced performance.
By default, serpack is built to run Javascript/Typescript, but it also supports module bundling!
Features
- ⚡ Lightning Fast: Your JavaScript/TypeScript file will be compiled it in the blink of an eye.
- 📦 Module Bunling: Bundle multiple files into one file.
- 🚀 TypeScript Supported: TypeScript compilation is also possible.
CLI
$ serpack <path>
Option | Description | Default | Type |
---|---|---|---|
--no-run | only build file | false | boolean |
--output, -o | provide outfile path | "cache.~.js" | string |
--sourcemap, -s | provide sourcemap path (experimental) | false | boolean | string |
--cli | whether js file is cli app | false | boolean |
--external | exclude node_modules from output | false | boolean |
TIP: A flag with a boolean type as its value, such as
--cli
, must specify true or false as--cli=true
APIs
compile
Compile a TypeScript or Javascript file in a executable code.
import { compile } from 'serpack';
compile('foo/bar.ts', {
/* options */
}).then(({ code }) => {
eval(code);
});
Option | Description | Default |
---|---|---|
nodeExternal | exclude node_modules from output | false |
externals | module to exclude | [] |
runtime | enable runtime (output size will be smaller) | [] |
parserOptions | Acorn parse options | {} |
globals | Global variable settings (swc) | |
resolverOptions | oxc-resolver options | {} |
type | Type (script | module ) | "module" |
banner | banner | "" |
footer | footer | "" |
🚧 The sourcemap generation is still under development.
importToRequire
Convert ImportStatement
to require.
const requireNode = importToRequire(node);
Supported Extensions
- JavaScript:
js
,cjs
,mjs
,jsx
- TypeScript:
ts
,cts
,mts
,tsx
- JSON:
json
TIP: If you want to load the file regardless of whether its extension is supported, set
options.type
toscript
.
Inmodule
mode, extension support is checked strictly, but inscript
mode, it is loaded unconditionally.
LICENSE
MIT
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
6 months ago
6 months ago
6 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
3 months ago
5 months ago
6 months ago
6 months ago
5 months ago
5 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago