Skip to content

Commit 66f1a87

Browse files
committed
test ci
1 parent 593df1a commit 66f1a87

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

packages/core/src/constant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const RSLIB_ENTRY_QUERY = '__rslib_entry__';
1414
export const SHEBANG_PREFIX = '#!';
1515
export const SHEBANG_REGEX: RegExp = /#!.*[\s\n\r]*/;
1616
export const REACT_DIRECTIVE_REGEX: RegExp =
17-
/^['"]use (client|server)['"](;?)$/;
17+
/^['"]use (client|server)['"](;?)[\s\n\r]*$/;
1818

1919
export const JS_EXTENSIONS: string[] = [
2020
'js',

packages/core/src/plugins/PostEntryChunkPlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createRequire } from 'node:module';
2+
import os from 'node:os';
23
import {
34
type RsbuildConfig,
45
type RsbuildPlugin,
@@ -17,7 +18,7 @@ const require = createRequire(import.meta.url);
1718
const PLUGIN_NAME = 'rsbuild:entry';
1819

1920
const matchFirstLine = (source: string, regex: RegExp) => {
20-
const [firstLine] = source.split('\n');
21+
const [firstLine] = source.split(os.EOL);
2122
if (!firstLine) {
2223
return false;
2324
}
@@ -154,7 +155,7 @@ class PostEntryPlugin {
154155
{
155156
name: PLUGIN_NAME,
156157
// Just after minify stage, to avoid from being minified.
157-
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
158+
stage: rspack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1,
158159
},
159160
(assets) => {
160161
const chunkAsset = Object.keys(assets);

packages/core/src/plugins/entryModuleLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'node:os';
12
import type { LoaderDefinition } from '@rspack/core';
23
import {
34
REACT_DIRECTIVE_REGEX,
@@ -14,7 +15,7 @@ const loader: LoaderDefinition = function loader(source) {
1415
result = rest1.join('\n');
1516
}
1617

17-
const [firstLine, ...rest2] = result.split('\n');
18+
const [firstLine, ...rest2] = result.split(os.EOL);
1819
if (REACT_DIRECTIVE_REGEX.test(firstLine!)) {
1920
result = rest2.join('\n');
2021
}

tests/integration/directive/index.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ describe('shebang', async () => {
77
const { entries } = await buildAndGetResults({ fixturePath });
88

99
test('shebang at the beginning', async () => {
10-
expect(entries.esm0!.startsWith('#!/usr/bin/env node\n')).toBe(true);
10+
console.log('😧1', entries.esm0!);
11+
expect(entries.esm0!.startsWith('#!/usr/bin/env node')).toBe(true);
1112
});
1213

1314
test('shebang at the beginning even if minified', async () => {
14-
expect(entries.esm1!.startsWith('#!/usr/bin/env node\n')).toBe(true);
15+
expect(entries.esm1!.startsWith('#!/usr/bin/env node')).toBe(true);
1516
});
1617
});
1718

@@ -23,6 +24,7 @@ describe('react', async () => {
2324
return path.basename(key) === 'bar.js';
2425
})?.[1];
2526

27+
console.log('😧2', bar!);
2628
expect(bar!.startsWith(`'use server';`)).toBe(true);
2729

2830
const foo = Object.entries(contents.esm0!).find(([key]) => {

tests/playwright.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export default defineConfig({
77
retries: process.env.CI ? 3 : 0,
88
// Print line for each test being run in CI
99
reporter: 'list',
10+
expect: {
11+
timeout: process.env.CI ? 10_000 : 5_000,
12+
},
1013
webServer: [
1114
{
1215
command: 'cd ../examples/module-federation && npm run dev:host',

0 commit comments

Comments
 (0)