Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .yarn/versions/6459c603.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
releases:
"@yarnpkg/builder": minor

declined:
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/cli"
11 changes: 6 additions & 5 deletions packages/yarnpkg-builder/sources/commands/build/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {getDynamicLibs} from '@yarnpkg/cli';
import {StreamReport, MessageName, Configuration, formatUtils, structUtils} from '@yarnpkg/core';
import {npath} from '@yarnpkg/fslib';
import {npath, ppath, xfs} from '@yarnpkg/fslib';
import chalk from 'chalk';
import cp from 'child_process';
import {Command, Option, Usage} from 'clipanion';
import {build, Plugin} from 'esbuild';
import fs from 'fs';
import {createRequire} from 'module';
import path from 'path';
import semver from 'semver';
Expand Down Expand Up @@ -79,7 +78,7 @@ export default class BuildBundleCommand extends Command {

const plugins = findPlugins({basedir, profile: this.profile, plugins: this.plugins.map(plugin => path.resolve(plugin))});
const modules = [...getDynamicLibs().keys()].concat(plugins);
const output = path.join(basedir, `bundles/yarn.js`);
const output = ppath.join(portableBaseDir, `bundles/yarn.js`);

let version = pkgJsonVersion(basedir);

Expand Down Expand Up @@ -132,7 +131,7 @@ export default class BuildBundleCommand extends Command {
'process.env.__FAKE_PLATFORM__': `false`,
}),
},
outfile: output,
outfile: npath.fromPortablePath(output),
// Default extensions + .mjs
resolveExtensions: [`.tsx`, `.ts`, `.jsx`, `.mjs`, `.js`, `.css`, `.json`],
logLevel: `silent`,
Expand All @@ -159,6 +158,8 @@ export default class BuildBundleCommand extends Command {
report.reportWarning(MessageName.UNNAMED, `${warning.location.file}:${warning.location.line}:${warning.location.column}`);
report.reportWarning(MessageName.UNNAMED, ` ↳ ${warning.text}`);
}

await xfs.chmodPromise(output, 0o755);
});
});

Expand All @@ -171,7 +172,7 @@ export default class BuildBundleCommand extends Command {
} else {
report.reportInfo(null, `${Mark.Check} Done building the CLI!`);
report.reportInfo(null, `${Mark.Question} Bundle path: ${formatUtils.pretty(configuration, output, formatUtils.Type.PATH)}`);
report.reportInfo(null, `${Mark.Question} Bundle size: ${formatUtils.pretty(configuration, fs.statSync(output).size, formatUtils.Type.SIZE)}`);
report.reportInfo(null, `${Mark.Question} Bundle size: ${formatUtils.pretty(configuration, (await xfs.statPromise(output)).size, formatUtils.Type.SIZE)}`);
report.reportInfo(null, `${Mark.Question} Bundle version: ${formatUtils.pretty(configuration, version, formatUtils.Type.REFERENCE)}`);

report.reportSeparator();
Expand Down
11 changes: 5 additions & 6 deletions packages/yarnpkg-builder/sources/commands/build/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {StreamReport, MessageName, Configuration, formatUtils, structUtils} from '@yarnpkg/core';
import {npath, xfs} from '@yarnpkg/fslib';
import {npath, ppath, xfs} from '@yarnpkg/fslib';
import {Command, Option, Usage, UsageError} from 'clipanion';
import {build, Plugin} from 'esbuild';
import fs from 'fs';
import path from 'path';
import semver from 'semver';

Expand Down Expand Up @@ -63,9 +62,9 @@ export default class BuildPluginCommand extends Command {
const {name: rawName, main} = require(`${basedir}/package.json`);
const name = getNormalizedName(rawName);
const prettyName = structUtils.prettyIdent(configuration, structUtils.parseIdent(name));
const output = path.join(basedir, `bundles/${name}.js`);
const output = ppath.join(portableBaseDir, `bundles/${name}.js`);

await xfs.mkdirPromise(npath.toPortablePath(path.dirname(output)), {recursive: true});
await xfs.mkdirPromise(ppath.dirname(output), {recursive: true});

const report = await StreamReport.start({
configuration,
Expand Down Expand Up @@ -113,7 +112,7 @@ export default class BuildPluginCommand extends Command {
},
entryPoints: [path.resolve(basedir, main ?? `sources/index`)],
bundle: true,
outfile: output,
outfile: npath.fromPortablePath(output),
// Default extensions + .mjs
resolveExtensions: [`.tsx`, `.ts`, `.jsx`, `.mjs`, `.js`, `.css`, `.json`],
logLevel: `silent`,
Expand Down Expand Up @@ -152,7 +151,7 @@ export default class BuildPluginCommand extends Command {
} else {
report.reportInfo(null, `${Mark.Check} Done building ${prettyName}!`);
report.reportInfo(null, `${Mark.Question} Bundle path: ${formatUtils.pretty(configuration, output, formatUtils.Type.PATH)}`);
report.reportInfo(null, `${Mark.Question} Bundle size: ${formatUtils.pretty(configuration, fs.statSync(output).size, formatUtils.Type.SIZE)}`);
report.reportInfo(null, `${Mark.Question} Bundle size: ${formatUtils.pretty(configuration, (await xfs.statPromise(output)).size, formatUtils.Type.SIZE)}`);
}

return report.exitCode();
Expand Down