Skip to content

Commit

Permalink
[build]: Replace node_modules with a single-file bundle produced by…
Browse files Browse the repository at this point in the history
… `ncc`

Detailed description of changes:

* Add `package` script to `package.json` that builds the TypeScript code
  and "links" it together with all of its (transitive) dependencies in a
  single `index.js` file.

* Change the `main` file in `package.json` to `dist/index.js`.
  `ncc` allows only the out dir can be specified - the filename is
  always `index.js`.

* Add `lib/` and `dist/*` to .gitingore, but exclude `dist/index.js` so
  it will be committed.

* Delete the `node_modules` and `lib` folders

* Add a `.gitattributes` file in order to set mark `dist/index.js` as
  `binary` for git diff and merge purposes

* Update `.gitignore` to the latest version from `https://github.com/github/gitignore/blob/master/Node.gitignore`

* Set the `target` in `tsconfig.json` to `es2017`, which is [supported by
  current Node.js version - v12][1], as should make for cleaner generated
  "down-leveled" code as it has native async/await support

[1]: https://node.green/
  • Loading branch information
PetarKirov committed Feb 9, 2021
1 parent a6d682f commit 4287ead
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 430 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mark .pnp.cjs as binary to prevent git from trying to merge it
/dist/index.js binary linguist-generated
/.pnp.* binary linguist-generated
/.yarn/releases/** binary linguist-generated

# Set the language for these files to json5 to ensure GitHub doesn't show the comments as errors
/.vscode/*.json linguist-language=JSON5
tsconfig.json linguist-language=JSON5
39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
__tests__/runner/*
lib/
dist/*
!dist/index.js

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
Expand Down Expand Up @@ -41,10 +44,11 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo
Expand All @@ -55,6 +59,12 @@ typings/
# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

Expand All @@ -70,13 +80,21 @@ typings/

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# next.js build output
# Next.js build output
.next
out

# nuxt.js build output
# Nuxt.js build / generate output
.nuxt

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

Expand All @@ -88,3 +106,16 @@ typings/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ inputs:
required: false
runs:
using: "node12"
main: "lib/main.js"
main: "dist/index.js"
1 change: 1 addition & 0 deletions dist/index.js

Large diffs are not rendered by default.

219 changes: 0 additions & 219 deletions lib/compiler.js

This file was deleted.

67 changes: 0 additions & 67 deletions lib/gpg.js

This file was deleted.

Loading

0 comments on commit 4287ead

Please sign in to comment.