0.1.19 • Published 3 months ago

serpack v0.1.19

Weekly downloads
-
License
-
Repository
github
Last release
3 months ago

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>
OptionDescriptionDefaultType
--no-runonly build filefalseboolean
--output, -oprovide outfile path"cache.~.js"string
--sourcemap, -sprovide sourcemap path (experimental)falseboolean | string
--cliwhether js file is cli appfalseboolean
--externalexclude node_modules from outputfalseboolean

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);
});
OptionDescriptionDefault
nodeExternalexclude node_modules from outputfalse
externalsmodule to exclude[]
runtimeenable runtime (output size will be smaller)[]
parserOptionsAcorn parse options{}
globalsGlobal variable settings (swc)
resolverOptionsoxc-resolver options{}
typeType (script | module)"module"
bannerbanner""
footerfooter""

🚧 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.typeto script.
In module mode, extension support is checked strictly, but in script mode, it is loaded unconditionally.

LICENSE

MIT

0.1.10

5 months ago

0.1.11

5 months ago

0.1.12

5 months ago

0.1.13

5 months ago

0.1.14

5 months ago

0.1.15

5 months ago

0.1.0

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.16

5 months ago

0.1.8

5 months ago

0.1.17

4 months ago

0.1.7

5 months ago

0.1.18

4 months ago

0.1.19

3 months ago

0.1.9

5 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.6

5 months ago

0.1.5

5 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

0.0.0

10 months ago