@leverege/build-tools 2.113.0-quinn.1 → 2.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/yarn-build.mjs +33 -13
package/package.json
CHANGED
package/src/yarn-build.mjs
CHANGED
|
@@ -32,11 +32,18 @@ log( `Building ${packageJson.name}...` )
|
|
|
32
32
|
|
|
33
33
|
const packageName = packageJson.name
|
|
34
34
|
const mainEntry = path.join( process.env.INIT_CWD, packageJson.main )
|
|
35
|
-
const root = findYarnWorkspaceRoot( process.env.INIT_CWD ) || process.env.INIT_CWD
|
|
36
35
|
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
36
|
+
// A null workspace root means this is a standalone (non-monorepo) package:
|
|
37
|
+
// there are no sibling workspaces to prune away, so turbo prune doesn't apply
|
|
38
|
+
// (it requires a workspace root and errors otherwise). In that case the
|
|
39
|
+
// package itself is the whole deployable.
|
|
40
|
+
const workspaceRoot = findYarnWorkspaceRoot( process.env.INIT_CWD )
|
|
41
|
+
const isMonorepo = workspaceRoot != null
|
|
42
|
+
const root = workspaceRoot || process.env.INIT_CWD
|
|
43
|
+
|
|
44
|
+
// Entry path relative to the deployable's root. For a monorepo turbo prune
|
|
45
|
+
// preserves the workspace layout under that root; for a standalone package the
|
|
46
|
+
// root is the package dir itself. Either way this resolves from the buildDir.
|
|
40
47
|
const main = path.relative( root, mainEntry )
|
|
41
48
|
|
|
42
49
|
// Same out-of-tree staging dir the old yarn-build used. docker-to-registry
|
|
@@ -51,15 +58,28 @@ log( 'Cleaning previous build output...' )
|
|
|
51
58
|
await $$`rm -rf ${buildDir}`.catch( () => {} )
|
|
52
59
|
await $$`mkdir -p ${buildDir}`.catch( () => {} )
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
if ( isMonorepo ) {
|
|
62
|
+
// Prune the monorepo down to the target package and only the workspaces it
|
|
63
|
+
// actually depends on (per package.json), emitting a pruned lockfile. No
|
|
64
|
+
// bundling / compilation: the servers run raw ESM source, so the pruned tree
|
|
65
|
+
// IS the deployable. node_modules is intentionally not copied; the Docker
|
|
66
|
+
// build installs from the pruned lockfile. Without --docker, turbo emits a
|
|
67
|
+
// flat pruned workspace tree (root package.json, workspace dirs, lockfile)
|
|
68
|
+
// directly into the out dir.
|
|
69
|
+
log( `Pruning workspace ${packageName}...` )
|
|
70
|
+
await $$`yarn dlx turbo@^2 prune ${packageName} --out-dir ${buildDir}`
|
|
71
|
+
} else {
|
|
72
|
+
// Standalone package: nothing to prune. Copy the package's tracked and
|
|
73
|
+
// non-ignored files into buildDir. `git ls-files --cached --others
|
|
74
|
+
// --exclude-standard` honors .gitignore, so node_modules and build cruft are
|
|
75
|
+
// excluded while the lockfile and package.json (both tracked) come along.
|
|
76
|
+
log( 'Standalone package (no workspace root); copying source, turbo prune skipped...' )
|
|
77
|
+
const listed = await $`git -C ${process.env.INIT_CWD} ls-files --cached --others --exclude-standard`
|
|
78
|
+
const files = listed.stdout.split( '\n' ).filter( Boolean )
|
|
79
|
+
await Promise.all( files.map( rel => (
|
|
80
|
+
fs.copy( path.join( process.env.INIT_CWD, rel ), path.join( buildDir, rel ) )
|
|
81
|
+
) ) )
|
|
82
|
+
}
|
|
63
83
|
|
|
64
84
|
log( 'Writing entrypoint...' )
|
|
65
85
|
const entrypointFile = generateEntrypointFile( main )
|