Merge pull request #663 from napi-rs/reduce-install-size
chore: reduce published size
This commit is contained in:
commit
cae08c5133
10 changed files with 39 additions and 1331 deletions
|
@ -12,3 +12,4 @@ temp
|
||||||
__mock__
|
__mock__
|
||||||
target
|
target
|
||||||
scripts
|
scripts
|
||||||
|
triples/index.js
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
target
|
target
|
||||||
node_modules
|
node_modules
|
||||||
scripts
|
scripts
|
||||||
|
triples/index.js
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
const { readFileSync, writeFileSync } = require('fs')
|
const { readFileSync, writeFileSync } = require('fs')
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
|
|
||||||
|
const esbuild = require('esbuild')
|
||||||
const { groupBy, mapValues } = require('lodash')
|
const { groupBy, mapValues } = require('lodash')
|
||||||
const prettier = require('prettier')
|
|
||||||
|
|
||||||
const { parseTriple } = require('./cli/scripts/parse-triple')
|
const { parseTriple } = require('./cli/scripts/parse-triple')
|
||||||
|
|
||||||
const rawLists = readFileSync(join(__dirname, 'triples', 'target-list'), 'utf8')
|
const RAW_LIST = readFileSync(join(__dirname, 'triples', 'target-list'), 'utf8')
|
||||||
|
|
||||||
const tripleLists = rawLists
|
const SUPPORTED_PLATFORM = new Set([
|
||||||
.trim()
|
'darwin',
|
||||||
|
'ios',
|
||||||
|
'android',
|
||||||
|
'win32',
|
||||||
|
'linux',
|
||||||
|
'freebsd',
|
||||||
|
])
|
||||||
|
|
||||||
|
const tripleLists = RAW_LIST.trim()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter((line) => !line.startsWith('wasm') && line.trim().length)
|
.filter((line) => !line.startsWith('wasm') && line.trim().length)
|
||||||
.map(parseTriple)
|
.map(parseTriple)
|
||||||
|
@ -19,22 +27,22 @@ const tripleLists = rawLists
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
const platformArchTriples = mapValues(
|
const platformArchTriples = mapValues(
|
||||||
groupBy([...Object.values(tripleLists)], 'platform'),
|
groupBy(
|
||||||
|
Object.values(tripleLists).filter((k) =>
|
||||||
|
SUPPORTED_PLATFORM.has(k.platform),
|
||||||
|
),
|
||||||
|
'platform',
|
||||||
|
),
|
||||||
(v) => groupBy(v, 'arch'),
|
(v) => groupBy(v, 'arch'),
|
||||||
)
|
)
|
||||||
|
|
||||||
const fileContent = `
|
const fileContent = `
|
||||||
module.exports = ${JSON.stringify(tripleLists, null, 2)}
|
|
||||||
|
|
||||||
module.exports.platformArchTriples = ${JSON.stringify(platformArchTriples)}
|
module.exports.platformArchTriples = ${JSON.stringify(platformArchTriples)}
|
||||||
`
|
`
|
||||||
|
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(__dirname, 'triples', 'index.js'),
|
join(__dirname, 'triples', 'index.js'),
|
||||||
prettier.format(fileContent, {
|
esbuild.transformSync(fileContent, {
|
||||||
semi: false,
|
minify: true,
|
||||||
singleQuote: true,
|
}).code,
|
||||||
trailingComma: 'es5',
|
|
||||||
parser: 'typescript',
|
|
||||||
}),
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
"benny": "^3.6.15",
|
"benny": "^3.6.15",
|
||||||
"c8": "^7.7.3",
|
"c8": "^7.7.3",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
"esbuild": "^0.12.15",
|
||||||
"eslint": "^7.31.0",
|
"eslint": "^7.31.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.23.4",
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# `@napi-rs/triples`
|
# `@napi-rs/triples`
|
||||||
|
|
||||||
|
[![install size](https://packagephobia.com/badge?p=@napi-rs/triples)](https://packagephobia.com/result?p=@napi-rs/triples)
|
||||||
|
[![Downloads](https://img.shields.io/npm/dm/@napi-rs/triples.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/triples?minimal=true)
|
||||||
|
|
||||||
> Rust build triples definitions
|
> Rust build triples definitions
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
10
triples/index.d.ts
vendored
10
triples/index.d.ts
vendored
|
@ -6,12 +6,8 @@ interface Triple {
|
||||||
raw: string
|
raw: string
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const Triples: Triple[] & {
|
export const platformArchTriples: {
|
||||||
platformArchTriples: {
|
[index: string]: {
|
||||||
[index: string]: {
|
[index: string]: Triple[]
|
||||||
[index: string]: Triple[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export = Triples
|
|
||||||
|
|
1310
triples/index.js
1310
triples/index.js
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,7 @@
|
||||||
"registry": "https://registry.npmjs.org/",
|
"registry": "https://registry.npmjs.org/",
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"files": ["index.js", "index.d.ts", "target-list"],
|
"files": ["index.js", "index.d.ts"],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/napi-rs/napi-rs.git"
|
"url": "git+https://github.com/napi-rs/napi-rs.git"
|
||||||
|
|
|
@ -72,9 +72,9 @@ x86_64-apple-ios
|
||||||
x86_64-fortanix-unknown-sgx
|
x86_64-fortanix-unknown-sgx
|
||||||
x86_64-fuchsia
|
x86_64-fuchsia
|
||||||
x86_64-linux-android
|
x86_64-linux-android
|
||||||
|
x86_64-pc-solaris
|
||||||
x86_64-pc-windows-gnu
|
x86_64-pc-windows-gnu
|
||||||
x86_64-pc-windows-msvc
|
x86_64-pc-windows-msvc
|
||||||
x86_64-rumprun-netbsd
|
|
||||||
x86_64-sun-solaris
|
x86_64-sun-solaris
|
||||||
x86_64-unknown-freebsd
|
x86_64-unknown-freebsd
|
||||||
x86_64-unknown-illumos
|
x86_64-unknown-illumos
|
||||||
|
|
|
@ -2604,6 +2604,11 @@ es-to-primitive@^1.2.1:
|
||||||
is-date-object "^1.0.1"
|
is-date-object "^1.0.1"
|
||||||
is-symbol "^1.0.2"
|
is-symbol "^1.0.2"
|
||||||
|
|
||||||
|
esbuild@^0.12.15:
|
||||||
|
version "0.12.15"
|
||||||
|
resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.12.15.tgz#9d99cf39aeb2188265c5983e983e236829f08af0"
|
||||||
|
integrity sha512-72V4JNd2+48eOVCXx49xoSWHgC3/cCy96e7mbXKY+WOWghN00cCmlGnwVLRhRHorvv0dgCyuMYBZlM2xDM5OQw==
|
||||||
|
|
||||||
escalade@^3.1.1:
|
escalade@^3.1.1:
|
||||||
version "3.1.1"
|
version "3.1.1"
|
||||||
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
|
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
|
||||||
|
@ -4441,6 +4446,7 @@ minipass-fetch@^1.3.0, minipass-fetch@^1.3.2:
|
||||||
resolved "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-1.3.3.tgz#34c7cea038c817a8658461bf35174551dce17a0a"
|
resolved "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-1.3.3.tgz#34c7cea038c817a8658461bf35174551dce17a0a"
|
||||||
integrity sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ==
|
integrity sha512-akCrLDWfbdAWkMLBxJEeWTdNsjML+dt5YgOI4gJ53vuO0vrmYQkUPxa6j6V65s9CcePIr2SSWqjT2EcrNseryQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
|
encoding "^0.1.12"
|
||||||
minipass "^3.1.0"
|
minipass "^3.1.0"
|
||||||
minipass-sized "^1.0.3"
|
minipass-sized "^1.0.3"
|
||||||
minizlib "^2.0.0"
|
minizlib "^2.0.0"
|
||||||
|
|
Loading…
Reference in a new issue