MCPcopy Create free account
hub / github.com/adobe/react-spectrum / build

Function build

perf/build.mjs:81–163  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

79}
80
81export async function build(name) {
82 let dir = buildPath(name);
83 await fs.mkdir(path.dirname(dir), {recursive: true});
84 // Named snapshots are immutable, so a baseline cannot be overwritten by accident.
85 await fs.mkdir(dir);
86 try {
87 console.log(`Building production snapshot ${name}…`);
88 let bundler = new parcel.Parcel({
89 entries: path.join(root, 'perf/app/index.html'),
90 config: path.join(root, 'perf/.parcelrc'),
91 mode: 'production',
92 env: {NODE_ENV: 'production'},
93 shouldAutoInstall: false,
94 cacheDir: path.join(local, 'cache'),
95 targets: {
96 benchmark: {
97 context: 'browser',
98 distDir: dir,
99 publicUrl: './',
100 outputFormat: 'esmodule',
101 includeNodeModules: true,
102 optimize: true,
103 scopeHoist: true,
104 sourceMap: false,
105 engines: {browsers: ['Chrome >= 120']}
106 }
107 }
108 });
109 let {bundleGraph} = await bundler.run();
110 let assets = new Set();
111 for (let bundle of bundleGraph.getBundles()) {
112 bundle.traverseAssets(asset =>
113 assets.add(path.relative(root, asset.filePath).replaceAll('\\', '/'))
114 );
115 }
116 let reactAssets = [...assets].filter(file => /node_modules\/react(-dom)?\//.test(file));
117 if (
118 !reactAssets.some(file => file.endsWith('react-dom-client.production.js')) ||
119 reactAssets.some(file => file.endsWith('.development.js'))
120 ) {
121 throw new Error(
122 'The bundle must contain production React DOM and no development React modules.'
123 );
124 }
125 for (let pkg of ['react-aria-components', 'react-aria', 'react-stately']) {
126 if (![...assets].some(file => file.startsWith(`packages/${pkg}/src/`))) {
127 throw new Error(`Expected ${pkg} to resolve to source in this checkout.`);
128 }
129 }
130 let git = (...args) =>
131 execFileSync('git', args, {cwd: root, encoding: 'utf8', maxBuffer: 32 * 1024 * 1024}).trim();
132 let manifest = {
133 schema: 1,
134 name,
135 created: new Date().toISOString(),
136 source: {
137 sha: git('rev-parse', 'HEAD'),
138 branch: git('branch', '--show-current'),

Callers 2

smokeFunction · 0.90
cli.mjsFile · 0.90

Calls 10

buildPathFunction · 0.85
gitFunction · 0.85
harnessHashFunction · 0.85
artifactHashFunction · 0.85
runMethod · 0.80
sliceMethod · 0.80
hashFunction · 0.70
addMethod · 0.65
filterMethod · 0.65
requireFunction · 0.50

Tested by

no test coverage detected