0.1.2 • Published 3 years ago

@zaydek/esnode v0.1.2

Weekly downloads
217
License
MIT
Repository
github
Last release
3 years ago

esnode

esnode is the answer to the question: How do I run JSX or TypeScript on the server without build-steps?

esnode builds on esbuild and source-map-support (thanks @evanw!) to enable transpilation on-the-fly for .js, .jsx, .ts, and .tsx files.

Note that esnode does not type-check at build-time. If this is important to you, you may want to use ts-node or Deno. Note that Deno is not largely compatible with the existing Node.js ecosystem. Therefore if type-checking at build-time and interoperability with Node.js is important to you, you may want to use ts-node or defer to VS Code and or tsc for type-checking.

Installation

To install esnode, simply install @zaydek/esnode and run ./node_modules/.bin/esnode.

NPM

npm i --save-dev @zaydek/esnode
./node_modules/.bin/esnode [file]

Yarn

yarn --dev @zaydek/esnode
./node_modules/.bin/esnode [file]

Finally, create and run a JSX or TypeScript file:

// hello.ts
function hello(who?: string): string {
	return `Hello, ${who ?? "world"}!`
}

console.log(hello())
% ./node_modules/.bin/esnode hello.ts
Hello, world!

For convenience, you may want to alias esnode as alias esnode=./node_modules/.bin/esnode. To alias esnode globally, add alias esnode=./node_modules/.bin/esnode to your ~/.bash_profile.

CLI

 esnode [file]

   esnode runs a JavaScript or TypeScript file using the Node.js runtime. This is
   almost the same as 'node [file]' except that 'esnode [file]' is compatible with
   '.js', '.jsx', '.ts', and '.tsx' files. You may even interoperate JavaScript and
   TypeScript.

   Your entry point and its dependencies are transpiled on-the-fly by esbuild.
   esbuild is configured to not bundle 'package.json' dependencies at build-time;
   these dependencies use 'require' at runtime.

   Note that '.ts' and '.tsx' files are not type-checked. You may use VS Code or the
   TypeScript CLI 'tsc' for type-checking. To add the TypeScript CLI, use
   'npm i --save-dev typescript' or 'yarn add --dev typescript'.

 Examples

   % ./node_modules/.bin/esnode hello.ts
   Hello, world!

   % alias esnode=./node_modules/.bin/esnode
   % esnode hello.ts
   Hello, world!

   % STACK_TRACE=true esnode hello.ts
   Hello, world!

 Repositories

   esnode:  https://github.com/zaydek/esnode
   esbuild: https://github.com/evanw/esbuild

License

Licensed as MIT open source.

0.0.20

3 years ago

0.0.21

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago