Skip to content

Commit f977d0c

Browse files
TINY-13550: Fix bedrock-auto error when using rspack bundler (#160)
Co-authored-by: ltrouton <[email protected]>
1 parent d5c976b commit f977d0c

File tree

7 files changed

+43
-13
lines changed

7 files changed

+43
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## Unreleased
8+
- Fixed an issue where using bedrock-auto with rspack bundling resulted in an error. #TINY-13550
9+
10+
# 15.1.0 - 2025-12-17
811

912
## Added
1013
- Add rspack dev server support. #TINY-12824

Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ timestamps {
6161
tinyNpm.withNpmPublishCredentials {
6262
// We need to tell git to ignore the changes to .npmrc when publishing
6363
exec('git update-index --assume-unchanged .npmrc')
64-
exec('yarn lerna publish from-package --yes --no-git-reset --ignore @ephox/bedrock-sample')
64+
// Re-evaluate whether we still need the `--no-verify-access` flag after upgrading Lerna (TINY-13539)
65+
exec('yarn lerna publish from-package --yes --no-git-reset --ignore @ephox/bedrock-sample --no-verify-access')
6566
}
6667
}
6768
}

modules/server/src/main/ts/bedrock/compiler/Compiler.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import * as fs from 'fs';
22
import * as Webpack from '../compiler/Webpack';
33
import * as Rspack from '../compiler/Rspack';
4+
import * as Types from './Types';
45

56
export interface Compiler {
67
readonly generate: () => Promise<Buffer | string>;
78
}
89

9-
export const compile = (bundler: 'webpack' | 'rspack', tsConfigFile: string, scratchDir: string, basedir: string, exitOnCompileError: boolean, files: string[], coverage: string[], polyfills: string[]): Compiler => {
10-
const getCompileFunc = () => {
10+
export const compile = (args: { bundler: Types.Bundler; tsConfigFile: string; scratchDir: string; basedir: string; exitOnCompileError: boolean; files: string[]; coverage: string[]; polyfills: string[];
11+
}): Compiler => {
12+
const {
13+
bundler,
14+
tsConfigFile,
15+
scratchDir,
16+
basedir,
17+
exitOnCompileError,
18+
files,
19+
coverage,
20+
polyfills
21+
} = args;
22+
23+
const getCompileFunc = (): Types.CompileFn => {
1124
switch (bundler) {
1225
case 'rspack':
1326
return Rspack.compile;

modules/server/src/main/ts/bedrock/compiler/Rspack.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ExitCodes } from '../util/ExitCodes';
66
import * as Imports from './Imports';
77
import { rspack, RspackOptions } from '@rspack/core';
88
import { RspackDevServer } from '@rspack/dev-server';
9-
import { RspackCompileInfo, DevServerServeSettings } from './Types';
9+
import { RspackCompileInfo, DevServerServeSettings, CompileFn } from './Types';
1010

1111
const getWebPackConfigTs = (tsConfigFile: string, scratchFile: string, dest: string, manualMode: boolean, basedir: string): RspackOptions => {
1212
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -60,6 +60,7 @@ const getWebPackConfigTs = (tsConfigFile: string, scratchFile: string, dest: str
6060
options: {
6161
jsc: {
6262
parser: { syntax: 'typescript', tsx: true },
63+
target: 'es2022',
6364
transform: {
6465
react: {
6566
runtime: 'automatic',
@@ -167,7 +168,7 @@ const getCompileInfo = (tsConfigFile: string, scratchDir: string, basedir: strin
167168
return getTsCompileInfo(tsConfigFile, scratchDir, basedir, manualMode);
168169
};
169170

170-
export const compile = async (tsConfigFile: string, scratchDir: string, basedir: string, exitOnCompileError: boolean, srcFiles: string[], polyfills: string[]): Promise<string> => {
171+
export const compile: CompileFn = async (tsConfigFile: string, scratchDir: string, basedir: string, exitOnCompileError: boolean, srcFiles: string[], _coverage: string[], polyfills: string[]): Promise<string> => {
171172
const compileInfo = await getCompileInfo(tsConfigFile, scratchDir, basedir, false);
172173
return compileTests(compileInfo, exitOnCompileError, srcFiles, polyfills);
173174
};

modules/server/src/main/ts/bedrock/compiler/Types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,14 @@ export interface CompileInfo<T> {
1717
readonly config: T;
1818
}
1919

20+
export type CompileFn = (
21+
tsConfigFile: string,
22+
scratchDir: string,
23+
basedir: string,
24+
exitOnCompileError: boolean,
25+
srcFiles: string[],
26+
coverage: string[],
27+
polyfills: string[]
28+
) => Promise<string>;
29+
30+
export type Bundler = 'rspack' | 'webpack';

modules/server/src/main/ts/bedrock/compiler/Webpack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as Serve from '../server/Serve';
77
import { ExitCodes } from '../util/ExitCodes';
88
import * as Imports from './Imports';
99
import { hasTs } from './TsUtils';
10-
import { WebpackCompileInfo, DevServerServeSettings } from './Types';
10+
import { WebpackCompileInfo, DevServerServeSettings, CompileFn } from './Types';
1111

1212
const webpackSharedRules = ([] as any[]).concat([
1313
{
@@ -258,7 +258,7 @@ const getCompileInfo = (tsConfigFile: string, scratchDir: string, basedir: strin
258258
}
259259
};
260260

261-
export const compile = async (tsConfigFile: string, scratchDir: string, basedir: string, exitOnCompileError: boolean, srcFiles: string[], coverage: string[], polyfills: string[]): Promise<string> => {
261+
export const compile: CompileFn = async (tsConfigFile: string, scratchDir: string, basedir: string, exitOnCompileError: boolean, srcFiles: string[], coverage: string[], polyfills: string[]): Promise<string> => {
262262
const compileInfo = await getCompileInfo(tsConfigFile, scratchDir, basedir, false, srcFiles, coverage);
263263
return compileTests(compileInfo, exitOnCompileError, srcFiles, polyfills);
264264
};

modules/server/src/main/ts/bedrock/server/RunnerRoutes.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as Routes from './Routes';
66
import * as Compiler from '../compiler/Compiler';
77
import * as FileUtils from '../util/FileUtils';
88
import * as Arr from '../util/Arr';
9+
import * as Types from '../compiler/Types';
910

1011
interface PackageJson {
1112
readonly name: string;
@@ -17,22 +18,22 @@ interface WorkspaceRoot {
1718
folder: string;
1819
}
1920

20-
export const generate = async (mode: string, projectdir: string, basedir: string, configFile: string, bundler: 'webpack' | 'rspack', testfiles: string[], chunk: number,
21+
export const generate = async (mode: string, projectdir: string, basedir: string, configFile: string, bundler: Types.Bundler, testfiles: string[], chunk: number,
2122
retries: number, singleTimeout: number, stopOnFailure: boolean, basePage: string, coverage: string[], polyfills: string[]): Promise<Routes.Runner> => {
2223
const files = testfiles.map((filePath) => {
2324
return path.relative(projectdir, filePath);
2425
});
2526

26-
const testGenerator = Compiler.compile(
27+
const testGenerator = Compiler.compile({
2728
bundler,
28-
path.join(projectdir, configFile),
29-
path.join(projectdir, 'scratch'),
29+
tsConfigFile: path.join(projectdir, configFile),
30+
scratchDir: path.join(projectdir, 'scratch'),
3031
basedir,
31-
mode === 'auto',
32+
exitOnCompileError: mode === 'auto',
3233
files,
3334
coverage,
3435
polyfills
35-
);
36+
});
3637

3738
// read the project json file to determine the project name to expose resources as `/project/${name}`
3839
const pkjson: PackageJson = FileUtils.readFileAsJson(`${projectdir}/package.json`);

0 commit comments

Comments
 (0)