@tamagui/build
Advanced tools
Comparing version 1.0.0-alpha.64 to 1.0.0-beta.172
{ | ||
"name": "@tamagui/build", | ||
"version": "1.0.0-alpha.64", | ||
"version": "1.0.0-beta.172+0f3fd8dc", | ||
"bin": { | ||
@@ -16,3 +16,3 @@ "tamagui-build": "tamagui-build.js" | ||
"chokidar": "^3.5.2", | ||
"esbuild": "^0.13.12", | ||
"esbuild": "^0.14.36", | ||
"execa": "^5.0.0", | ||
@@ -27,3 +27,3 @@ "fast-glob": "^3.2.7", | ||
}, | ||
"gitHead": "9363f43117f9504de9bd4949ca210cd1ebbf753b" | ||
"gitHead": "0f3fd8dc83eede20419fb180704eb9ad1d63e814" | ||
} |
@@ -9,3 +9,2 @@ #!/usr/bin/env node | ||
const createExternalPlugin = require('./externalNodePlugin') | ||
const path = require('path') | ||
@@ -15,165 +14,184 @@ const jsOnly = !!process.env.JS_ONLY | ||
const shouldSkipTypes = !!(process.argv.includes('skip-types') || process.env.SKIP_TYPES) | ||
const shouldClean = !!process.argv.includes('clean') | ||
const shouldCleanBuildOnly = !!process.argv.includes('clean:build') | ||
const shouldWatch = process.argv.includes('--watch') | ||
let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL | ||
const pkg = fs.readJSONSync('./package.json') | ||
const pkgMain = pkg.main | ||
const pkgModule = pkg.module | ||
async function build() { | ||
console.log('»', pkg.name) | ||
const x = Date.now() | ||
let files = (await fg(['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.css'])).filter( | ||
(x) => !x.includes('.d.ts') | ||
) | ||
if (shouldClean || shouldCleanBuildOnly) { | ||
;(async () => { | ||
try { | ||
await Promise.allSettled([fs.remove('.turbo'), fs.remove('types'), fs.remove('dist')]) | ||
} catch {} | ||
if (shouldCleanBuildOnly) { | ||
console.log('» cleaned', pkg.name) | ||
process.exit(0) | ||
} | ||
try { | ||
await Promise.allSettled([fs.remove('node_modules')]) | ||
} catch {} | ||
console.log('» cleaned', pkg.name) | ||
process.exit(0) | ||
})() | ||
} else { | ||
let shouldSkipInitialTypes = !!process.env.SKIP_TYPES_INITIAL | ||
if (process.env.NO_CLEAN) { | ||
console.log('skip typecheck') | ||
} else { | ||
fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo') | ||
} | ||
const pkgMain = pkg.main | ||
const pkgModule = pkg.module | ||
async function buildTsc() { | ||
if (jsOnly || shouldSkipTypes) return | ||
if (shouldSkipInitialTypes) { | ||
shouldSkipInitialTypes = false | ||
return | ||
async function build() { | ||
console.log('»', pkg.name) | ||
const x = Date.now() | ||
let files = (await fg(['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.css'])).filter( | ||
(x) => !x.includes('.d.ts') | ||
) | ||
if (process.env.NO_CLEAN) { | ||
console.log('skip typecheck') | ||
} else { | ||
fs.existsSync('tsconfig.tsbuildinfo') && fs.rmSync('tsconfig.tsbuildinfo') | ||
} | ||
// NOTE: | ||
// for Intellisense to work in monorepo you need baseUrl: "../.." | ||
// but to build things nicely we need here to reset a few things: | ||
// baseUrl: ., outDir: types, rootDir: src | ||
// now we can have the best of both worlds | ||
await fs.remove('types') | ||
async function buildTsc() { | ||
if (jsOnly || shouldSkipTypes) return | ||
if (shouldSkipInitialTypes) { | ||
shouldSkipInitialTypes = false | ||
return | ||
} | ||
// NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package... | ||
// (like tamagui does with @tamagui/core...) | ||
// we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that | ||
// but then it causes it to not export the types out from index... so.... | ||
// we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after | ||
// honestly hate typescript config all around but this seems to work so fuck it | ||
const tsConfOg = await fs.readFile('tsconfig.json') | ||
const tsConfJSON = json5.parse(tsConfOg) | ||
if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) { | ||
tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts') | ||
await fs.writeJSON('tsconfig.json', tsConfJSON) | ||
// NOTE: | ||
// for Intellisense to work in monorepo you need baseUrl: "../.." | ||
// but to build things nicely we need here to reset a few things: | ||
// baseUrl: ., outDir: types, rootDir: src | ||
// now we can have the best of both worlds | ||
// NOTE: to get intellisense to *not* suggest importing from the index file when it re-exports another package... | ||
// (like tamagui does with @tamagui/core...) | ||
// we add `exclude: ['src/index.ts']` to the tsconfig.json which fixes that | ||
// but then it causes it to not export the types out from index... so.... | ||
// we do a stupid, stupid thing to re-write it temporarily without it before build. then restore it after | ||
// honestly hate typescript config all around but this seems to work so fuck it | ||
const tsConfOg = await fs.readFile('tsconfig.json') | ||
const tsConfJSON = json5.parse(tsConfOg) | ||
if (tsConfJSON.exclude && tsConfJSON.exclude.includes('src/index.ts')) { | ||
tsConfJSON.exclude = tsConfJSON.exclude.filter((x) => x !== 'src/index.ts') | ||
await fs.writeJSON('tsconfig.json', tsConfJSON) | ||
} | ||
try { | ||
await exec('npx', [ | ||
'tsc', | ||
'--baseUrl', | ||
'.', | ||
'--outDir', | ||
'types', | ||
'--rootDir', | ||
'src', | ||
'--declaration', | ||
'--emitDeclarationOnly', | ||
'--declarationMap', | ||
]) | ||
} finally { | ||
// restore | ||
await fs.writeFile('tsconfig.json', tsConfOg) | ||
} | ||
} | ||
const externalPlugin = createExternalPlugin({ | ||
skipNodeModulesBundle: true, | ||
}) | ||
try { | ||
await exec('npx', [ | ||
'tsc', | ||
'--baseUrl', | ||
'.', | ||
'--outDir', | ||
'types', | ||
'--rootDir', | ||
'src', | ||
'--declaration', | ||
'--emitDeclarationOnly', | ||
'--declarationMap', | ||
await Promise.all([ | ||
buildTsc(), | ||
...(skipJS | ||
? [] | ||
: [ | ||
pkgMain | ||
? esbuild | ||
.build({ | ||
entryPoints: files, | ||
outdir: 'dist/cjs', | ||
bundle: false, | ||
sourcemap: true, | ||
target: 'node16', | ||
keepNames: true, | ||
format: 'cjs', | ||
color: true, | ||
logLevel: 'error', | ||
plugins: [externalPlugin], | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> commonjs') | ||
}) | ||
: null, | ||
// dont bundle for tree shaking | ||
pkgModule | ||
? esbuild | ||
.build({ | ||
entryPoints: files, | ||
outdir: 'dist/esm', | ||
sourcemap: true, | ||
target: 'es2019', | ||
keepNames: true, | ||
format: 'esm', | ||
color: true, | ||
logLevel: 'error', | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> esm') | ||
}) | ||
: null, | ||
esbuild | ||
.build({ | ||
// only diff is jsx preserve and outdir | ||
jsx: 'preserve', | ||
outdir: 'dist/jsx', | ||
entryPoints: files, | ||
sourcemap: false, | ||
target: 'es2019', | ||
keepNames: true, | ||
format: 'esm', | ||
color: true, | ||
logLevel: 'error', | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> jsx') | ||
}), | ||
]), | ||
]) | ||
} catch (error) { | ||
console.log('error', error) | ||
} finally { | ||
// restore | ||
await fs.writeFile('tsconfig.json', tsConfOg) | ||
console.log('built in', `${(Date.now() - x) / 1000}s`) | ||
} | ||
} | ||
const externalPlugin = createExternalPlugin({ | ||
skipNodeModulesBundle: true, | ||
}) | ||
try { | ||
await Promise.all([ | ||
buildTsc(), | ||
...(skipJS | ||
? [] | ||
: [ | ||
pkgMain | ||
? esbuild | ||
.build({ | ||
entryPoints: files, | ||
outdir: 'dist/cjs', | ||
bundle: false, | ||
sourcemap: true, | ||
target: 'node16', | ||
keepNames: true, | ||
format: 'cjs', | ||
color: true, | ||
logLevel: 'error', | ||
plugins: [externalPlugin], | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> commonjs') | ||
}) | ||
: null, | ||
// dont bundle for tree shaking | ||
pkgModule | ||
? esbuild | ||
.build({ | ||
entryPoints: files, | ||
outdir: 'dist/esm', | ||
sourcemap: true, | ||
target: 'es2019', | ||
keepNames: true, | ||
format: 'esm', | ||
color: true, | ||
logLevel: 'error', | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> esm') | ||
}) | ||
: null, | ||
esbuild | ||
.build({ | ||
// only diff is jsx preserve and outdir | ||
jsx: 'preserve', | ||
outdir: 'dist/jsx', | ||
entryPoints: files, | ||
sourcemap: false, | ||
target: 'es2019', | ||
keepNames: true, | ||
format: 'esm', | ||
color: true, | ||
logLevel: 'error', | ||
minify: false, | ||
platform: 'neutral', | ||
}) | ||
.then(() => { | ||
console.log(' >-> jsx') | ||
}), | ||
]), | ||
]) | ||
} catch (error) { | ||
console.log('error', error) | ||
} finally { | ||
console.log('built in', `${(Date.now() - x) / 1000}s`) | ||
if (shouldWatch) { | ||
const path = require('path') | ||
process.env.IS_WATCHING = true | ||
process.env.DISABLE_AUTORUN = true | ||
build().then(() => { | ||
const finish = (_, path, stats) => { | ||
build() | ||
} | ||
const chokidar = require('chokidar') | ||
chokidar | ||
// prevent infinite loop but cause race condition if you just build directly | ||
.watch('src', { | ||
persistent: true, | ||
alwaysStat: true, | ||
ignoreInitial: true, | ||
}) | ||
.on('change', finish) | ||
.on('add', finish) | ||
}) | ||
} else { | ||
build() | ||
} | ||
} | ||
if (shouldWatch) { | ||
const path = require('path') | ||
process.env.IS_WATCHING = true | ||
process.env.DISABLE_AUTORUN = true | ||
build().then(() => { | ||
const finish = (_, path, stats) => { | ||
build() | ||
} | ||
const chokidar = require('chokidar') | ||
chokidar | ||
// prevent infinite loop but cause race condition if you just build directly | ||
.watch('src', { | ||
persistent: true, | ||
alwaysStat: true, | ||
ignoreInitial: true, | ||
}) | ||
.on('change', finish) | ||
.on('add', finish) | ||
}) | ||
} else { | ||
build() | ||
} |
{ | ||
"extends": "../../tsconfig.json", | ||
"include": [], | ||
"files": [], | ||
"compilerOptions": { | ||
@@ -4,0 +6,0 @@ "composite": true, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8871
219
1
+ Added@esbuild/linux-loong64@0.14.54(transitive)
+ Addedesbuild@0.14.54(transitive)
+ Addedesbuild-android-64@0.14.54(transitive)
+ Addedesbuild-android-arm64@0.14.54(transitive)
+ Addedesbuild-darwin-64@0.14.54(transitive)
+ Addedesbuild-darwin-arm64@0.14.54(transitive)
+ Addedesbuild-freebsd-64@0.14.54(transitive)
+ Addedesbuild-freebsd-arm64@0.14.54(transitive)
+ Addedesbuild-linux-32@0.14.54(transitive)
+ Addedesbuild-linux-64@0.14.54(transitive)
+ Addedesbuild-linux-arm@0.14.54(transitive)
+ Addedesbuild-linux-arm64@0.14.54(transitive)
+ Addedesbuild-linux-mips64le@0.14.54(transitive)
+ Addedesbuild-linux-ppc64le@0.14.54(transitive)
+ Addedesbuild-linux-riscv64@0.14.54(transitive)
+ Addedesbuild-linux-s390x@0.14.54(transitive)
+ Addedesbuild-netbsd-64@0.14.54(transitive)
+ Addedesbuild-openbsd-64@0.14.54(transitive)
+ Addedesbuild-sunos-64@0.14.54(transitive)
+ Addedesbuild-windows-32@0.14.54(transitive)
+ Addedesbuild-windows-64@0.14.54(transitive)
+ Addedesbuild-windows-arm64@0.14.54(transitive)
- Removedesbuild@0.13.15(transitive)
- Removedesbuild-android-arm64@0.13.15(transitive)
- Removedesbuild-darwin-64@0.13.15(transitive)
- Removedesbuild-darwin-arm64@0.13.15(transitive)
- Removedesbuild-freebsd-64@0.13.15(transitive)
- Removedesbuild-freebsd-arm64@0.13.15(transitive)
- Removedesbuild-linux-32@0.13.15(transitive)
- Removedesbuild-linux-64@0.13.15(transitive)
- Removedesbuild-linux-arm@0.13.15(transitive)
- Removedesbuild-linux-arm64@0.13.15(transitive)
- Removedesbuild-linux-mips64le@0.13.15(transitive)
- Removedesbuild-linux-ppc64le@0.13.15(transitive)
- Removedesbuild-netbsd-64@0.13.15(transitive)
- Removedesbuild-openbsd-64@0.13.15(transitive)
- Removedesbuild-sunos-64@0.13.15(transitive)
- Removedesbuild-windows-32@0.13.15(transitive)
- Removedesbuild-windows-64@0.13.15(transitive)
- Removedesbuild-windows-arm64@0.13.15(transitive)
Updatedesbuild@^0.14.36