Skip to content

Commit d3463c5

Browse files
committed
fix(ci): run PSLB in scripts/release build so next publishes include module/ PIE-165
1 parent 8ab147d commit d3463c5

3 files changed

Lines changed: 84 additions & 6 deletions

File tree

scripts/build

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class ElementsCommands extends Commands {
5959
}
6060

6161
async sharedBuild() {
62+
// eslint-disable-next-line global-require, import/no-dynamic-require
63+
const pslbConfig = require(resolve(__dirname, '../pslb/pslb.config.js'));
64+
const pslbAllowed = new Set(pslbConfig.packages || []);
65+
6266
const root = resolve(__dirname, '../packages');
6367
const allPackages = readdirSync(root);
6468
const pkgJson = await Promise.all(
@@ -68,12 +72,25 @@ class ElementsCommands extends Commands {
6872
}),
6973
);
7074

71-
const printPkgs = pkgJson.filter((p) => p.pkg.exports && p.pkg.exports['./print']);
75+
const withPrint = pkgJson.filter((p) => p.pkg.exports && p.pkg.exports['./print']);
76+
const printPkgs = withPrint.filter((p) => pslbAllowed.has(p.pkg.name));
77+
const skipped = withPrint.filter((p) => !pslbAllowed.has(p.pkg.name)).map((p) => p.pkg.name);
78+
if (skipped.length > 0) {
79+
console.warn(
80+
'[sharedBuild] skipping pslb for packages with ./print not in pslb.config.js:',
81+
skipped.join(', '),
82+
);
83+
}
7284
console.log(
73-
'printPkgs',
85+
'printPkgs (pslb)',
7486
printPkgs.map((p) => p.dir),
7587
);
7688

89+
if (printPkgs.length === 0) {
90+
console.warn('[sharedBuild] no pslb-eligible print packages; skipping pslb');
91+
return Promise.resolve();
92+
}
93+
7794
const cmd = `yarn pslb --config pslb/pslb.config.js ${printPkgs.map(toPkgFlag).join(' ')} --logLevel silly`;
7895

7996
return this.runCmd(cmd);

scripts/build-print

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ const applyVersion = async (p, version) => {
4545
};
4646

4747
const run = async () => {
48+
// eslint-disable-next-line global-require, import/no-dynamic-require
49+
const pslbConfig = require(path.resolve(__dirname, '../pslb/pslb.config.js'));
50+
const pslbAllowed = new Set(pslbConfig.packages || []);
51+
4852
const root = path.resolve(__dirname, '../packages');
4953
const allPackages = readdirSync(root);
5054
const pkgJson = await Promise.all(
@@ -54,11 +58,17 @@ const run = async () => {
5458
})
5559
);
5660

57-
const printPkgs = pkgJson.filter(
58-
(p) => p.pkg.exports && p.pkg.exports['./print']
59-
);
61+
const withPrint = pkgJson.filter((p) => p.pkg.exports && p.pkg.exports['./print']);
62+
const printPkgs = withPrint.filter((p) => pslbAllowed.has(p.pkg.name));
63+
const skipped = withPrint.filter((p) => !pslbAllowed.has(p.pkg.name)).map((p) => p.pkg.name);
64+
if (skipped.length > 0) {
65+
console.warn(
66+
'[build-print] skipping pslb for packages with ./print not in pslb.config.js:',
67+
skipped.join(', ')
68+
);
69+
}
6070
console.log(
61-
'printPkgs',
71+
'printPkgs (pslb)',
6272
printPkgs.map((p) => p.dir)
6373
);
6474

@@ -69,6 +79,8 @@ const run = async () => {
6979
if (args.build) {
7080
if (args.dryRun) {
7181
console.log('build: dryRun - skip');
82+
} else if (printPkgs.length === 0) {
83+
console.warn('build-print: no pslb-eligible print packages; skipping pslb');
7284
} else {
7385
execSync(cmd, { stdio: 'inherit', cwd: path.resolve(__dirname, '..') });
7486
}

scripts/release

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
const { execSync } = require('child_process');
4+
const fs = require('fs');
45
const os = require('os');
56
const chalk = require('chalk');
67
const minimist = require('minimist');
@@ -106,13 +107,58 @@ const runCmd = (command, options = {}) => {
106107
const getCurrentBranch = () =>
107108
execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
108109

110+
/**
111+
* Builds print bundles under each element package's module directory (same as scripts/build sharedBuild).
112+
* Only packages that both declare a ./print export and appear in pslb/pslb.config.js `packages` get pslb
113+
* (blacklisted dirs like math-inline, select-text are excluded there).
114+
*/
115+
const buildPrintModules = () => {
116+
// eslint-disable-next-line global-require, import/no-dynamic-require
117+
const pslbConfig = require(resolve(CWD, 'pslb/pslb.config.js'));
118+
const pslbAllowed = new Set(pslbConfig.packages || []);
119+
120+
const packagesRoot = resolve(CWD, 'packages');
121+
const dirNames = fs.readdirSync(packagesRoot);
122+
const withPrintExport = [];
123+
124+
for (const d of dirNames) {
125+
const pkgPath = resolve(packagesRoot, d, 'package.json');
126+
if (!fs.existsSync(pkgPath)) {
127+
continue;
128+
}
129+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
130+
if (pkg.exports && pkg.exports['./print']) {
131+
withPrintExport.push(pkg.name);
132+
}
133+
}
134+
135+
const printPkgNames = withPrintExport.filter((n) => pslbAllowed.has(n));
136+
const skipped = withPrintExport.filter((n) => !pslbAllowed.has(n));
137+
if (skipped.length > 0) {
138+
warn(
139+
'Skipping pslb for packages with ./print but not in pslb.config.js packages list:',
140+
skipped.join(', '),
141+
);
142+
}
143+
144+
if (printPkgNames.length === 0) {
145+
warn('No pslb-eligible packages with ./print export; skipping pslb');
146+
return;
147+
}
148+
149+
log('print packages for pslb:', printPkgNames.join(', '));
150+
const pkgFlags = printPkgNames.map((n) => `--package ${n}`).join(' ');
151+
runCmd(`yarn pslb --config pslb/pslb.config.js ${pkgFlags} --logLevel silly`);
152+
};
153+
109154
/**
110155
* Executes the build process, which consists of multiple sequential steps including:
111156
*
112157
* 1. Cleanup: Removes generated `lib` directories for all packages in the repository.
113158
* 2. Linting: Runs ESLint across specified source files with defined extensions.
114159
* 3. Transpilation: Uses Babel to build the code from source to output directories (`lib`)
115160
* while generating source maps and respecting defined ignore rules.
161+
* 4. Print modules: Runs pslb for packages with ./print that are listed in pslb.config.js (matches yarn build).
116162
*/
117163
const build = () => {
118164
log(chalk.magenta('--- STEP 1: CLEANUP ---'));
@@ -129,6 +175,9 @@ const build = () => {
129175
runCmd(
130176
`${binary(`lerna`)} exec -- ${binary('babel')} --ignore \'**/__test__/**\',\'**/__tests__/**\' src -d lib --source-maps --root-mode upward`,
131177
);
178+
179+
log(chalk.magenta('--- STEP 4: PRINT MODULES (pslb) ---'));
180+
buildPrintModules();
132181
};
133182

134183
/**

0 commit comments

Comments
 (0)