Skip to content

Commit

Permalink
feat: shared build
Browse files Browse the repository at this point in the history
  • Loading branch information
ycjcl868 committed Jan 6, 2025
1 parent 2c8336c commit 86107c2
Show file tree
Hide file tree
Showing 8 changed files with 23,258 additions and 20,806 deletions.
17 changes: 4 additions & 13 deletions packages/native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process')
.execSync('which ldd')
.toString()
.trim()
const lddPath = require('child_process').execSync('which ldd').toString().trim();
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
return true
Expand All @@ -35,9 +32,7 @@ switch (platform) {
case 'android':
switch (arch) {
case 'arm64':
localFileExisted = existsSync(
join(__dirname, 'native.android-arm64.node')
)
localFileExisted = existsSync(join(__dirname, 'native.android-arm64.node'))
try {
if (localFileExisted) {
nativeBinding = require('./native.android-arm64.node')
Expand All @@ -49,9 +44,7 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(
join(__dirname, 'native.android-arm-eabi.node')
)
localFileExisted = existsSync(join(__dirname, 'native.android-arm-eabi.node'))
try {
if (localFileExisted) {
nativeBinding = require('./native.android-arm-eabi.node')
Expand Down Expand Up @@ -115,9 +108,7 @@ switch (platform) {
}
break
case 'darwin':
localFileExisted = existsSync(
join(__dirname, 'native.darwin-universal.node')
)
localFileExisted = existsSync(join(__dirname, 'native.darwin-universal.node'))
try {
if (localFileExisted) {
nativeBinding = require('./native.darwin-universal.node')
Expand Down
39 changes: 20 additions & 19 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,37 @@
"private": true,
"description": "An infrastructure monorepo shared library for all projects and apps.",
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p tsconfig.json && echo '{\"type\": \"module\"}' > dist/esm/package.json",
"build:cjs": "tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
"prepack": "npm run build:esm && npm run build:cjs",
"prepare": "npm run build",
"dev": "tsup --watch",
"build": "tsup"
"dev": "tsc -p tsconfig.json --watch"
},
"browser": {
"./types": "./dist/types/index.js",
"./utils": "./dist/utils/index.js"
"./types": "./dist/esm/types/index.js",
"./utils": "./dist/esm/utils/index.js"
},
"exports": {
"./types": {
"import": "./dist/types/index.mjs",
"require": "./dist/types/index.js"
},
"./utils": {
"import": "./dist/utils/index.mjs",
"require": "./dist/utils/index.js"
},
"./configs/*.json": "./configs/*.json",
"./configs/*": {
"require": "./dist/configs/*.js",
"import": "./dist/configs/*.mjs",
"types": "./dist/configs/*.d.ts"
"./configs/*": "./configs/*",
"./*": {
"import": "./dist/esm/*",
"require": "./dist/cjs/*"
}
},
"files": [
"dist",
"configs"
],
"devDependencies": {
"tsup": "^5.12.1",
"typescript": "^4.7.4",
"windicss": "^3.5.1"
},
"keywords": ["shared", "utils", "types"],
"keywords": [
"shared",
"utils",
"types"
],
"author": "ycjcl868",
"license": "ISC"
}
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/shared/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist/cjs"
},
"exclude": ["**/*.test.ts"]
}
9 changes: 6 additions & 3 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"extends": "./configs/tsconfig.base.json",
"compilerOptions": {
"outDir": "./dist/esm",
"declaration": true,
"target": "es6",
"module": "commonjs",
"declarationMap": true,
"target": "es2018",
"module": "Node16",
"moduleResolution": "Node16",
"baseUrl": "."
},
"include": ["**/*.ts"]
"include": ["src/**/*"]
}
9 changes: 0 additions & 9 deletions packages/shared/tsup.config.ts

This file was deleted.

Loading

0 comments on commit 86107c2

Please sign in to comment.