Skip to content

Ship only production runtime files#7

Open
osher wants to merge 1 commit into
stoplightio:masterfrom
osher:patch-1
Open

Ship only production runtime files#7
osher wants to merge 1 commit into
stoplightio:masterfrom
osher:patch-1

Conversation

@osher

@osher osher commented May 5, 2024

Copy link
Copy Markdown

Motivation and Context

This will reduce your node_modules footprint by 43% (from 956.0K to 552K) and your package size in similar ratio from 85K to 46K.

#InsertIssueNumberHere

Description

Here's what you're currently shipping:

$ du -ah node_modules/@stoplight/yaml-ast-parser
4.0K    node_modules/@stoplight/yaml-ast-parser/src/exception.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/common.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/yamlAST.ts
52.0K   node_modules/@stoplight/yaml-ast-parser/src/loader.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/scalarInference.ts
32.0K   node_modules/@stoplight/yaml-ast-parser/src/dumper.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema/default_safe.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema/core.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema/default_full.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema/failsafe.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema/json.ts
24.0K   node_modules/@stoplight/yaml-ast-parser/src/schema
4.0K    node_modules/@stoplight/yaml-ast-parser/src/mark.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/index.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/schema.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/str.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/js/regexp.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/js/function.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/js/undefined.ts
16.0K   node_modules/@stoplight/yaml-ast-parser/src/type/js
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/null.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/map.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/merge.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/set.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/int.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/float.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/bool.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/seq.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/omap.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/pairs.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/timestamp.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/src/type/binary.ts
72.0K   node_modules/@stoplight/yaml-ast-parser/src/type
216.0K  node_modules/@stoplight/yaml-ast-parser/src
4.0K    node_modules/@stoplight/yaml-ast-parser/README.md
4.0K    node_modules/@stoplight/yaml-ast-parser/test/yamlSyntax.test.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/test/visitor.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/test/loader.test.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/test/testUtil.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/test/stability.test.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/test/characterSet.test.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/test/scalarInference.test.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/test/dumper.test.ts
48.0K   node_modules/@stoplight/yaml-ast-parser/test
4.0K    node_modules/@stoplight/yaml-ast-parser/tsconfig.json
4.0K    node_modules/@stoplight/yaml-ast-parser/workspace.json
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/exception.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/yamlAST.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/yamlAST.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/common.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/scalarInference.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/mark.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/common.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/exception.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/scalarInference.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/mark.js
28.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/dumper.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type.d.ts
52.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/loader.js
52.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/loader.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/index.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema.js
28.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/dumper.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/loader.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/index.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/scalarInference.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_safe.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/failsafe.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/failsafe.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/core.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_full.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/json.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/core.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/json.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_full.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/failsafe.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/json.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_safe.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_full.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/core.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema/default_safe.js
64.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/schema
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/yamlAST.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/mark.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/exception.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/index.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/dumper.d.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/int.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/bool.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/merge.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/set.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/timestamp.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/bool.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/binary.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/merge.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/undefined.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/function.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/undefined.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/regexp.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/regexp.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/function.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/regexp.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/function.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/js/undefined.js.map
40.0K   node_modules/@stoplight/yaml-ast-parser/dist/src/type/js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/null.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/seq.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/merge.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/null.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/set.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/null.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/float.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/timestamp.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/int.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/pairs.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/float.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/pairs.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/seq.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/str.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/set.js
8.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/int.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/omap.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/seq.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/binary.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/float.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/str.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/map.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/timestamp.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/map.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/str.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/pairs.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/omap.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/omap.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/map.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/binary.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/type/bool.js
208.0K  node_modules/@stoplight/yaml-ast-parser/dist/src/type
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/common.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/src/schema.d.ts
540.0K  node_modules/@stoplight/yaml-ast-parser/dist/src
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/characterSet.test.js
8.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/dumper.test.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/visitor.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/loader.test.d.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/scalarInference.test.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/characterSet.test.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/dumper.test.d.ts
8.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/scalarInference.test.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/visitor.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/yamlSyntax.test.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/loader.test.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/characterSet.test.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/testUtil.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/testUtil.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/yamlSyntax.test.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/stability.test.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/loader.test.js.map
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/scalarInference.test.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/stability.test.d.ts
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/yamlSyntax.test.js.map
12.0K   node_modules/@stoplight/yaml-ast-parser/dist/test/dumper.test.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/testUtil.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/visitor.js
4.0K    node_modules/@stoplight/yaml-ast-parser/dist/test/stability.test.js
120.0K  node_modules/@stoplight/yaml-ast-parser/dist/test
664.0K  node_modules/@stoplight/yaml-ast-parser/dist
4.0K    node_modules/@stoplight/yaml-ast-parser/license.txt
4.0K    node_modules/@stoplight/yaml-ast-parser/package.json
4.0K    node_modules/@stoplight/yaml-ast-parser/.travis.yml
956.0K  node_modules/@stoplight/yaml-ast-parser

All these are not necessary on production

  • raw sources (when transpiling)
  • test files
  • development & ci config files

How Has This Been Tested?

I did not change code, only packing method.

Here's my test:

  1. take a base line
npm i
tsc
npm pack
mv yaml-ast-parser-0.0.43.tgz yaml-ast-parser-0.0.43.before.tgz
  1. perform the changes in package.json
  2. test for regression
npm pack
mkdir tmp && cd tmp && npm init -y 
npm i ../yaml-ast-parser-0.0.43.tgz
node -p 'require("yaml-ast-parser")'

expect a shell inspect descriptor of your package.

  1. compare
$ ls -lah *.tgz
-rw-r--r-- 1 osher osher 85K May  5 21:38 yaml-ast-parser-0.0.43.before.tgz
-rw-r--r-- 1 osher osher 46K May  5 21:42 yaml-ast-parser-0.0.43.tgz

Screenshot(s)/recordings(s)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant