File tree Expand file tree Collapse file tree 4 files changed +10
-6
lines changed
tests/integration/directive Expand file tree Collapse file tree 4 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export const RSLIB_ENTRY_QUERY = '__rslib_entry__';
1414export const SHEBANG_PREFIX = '#!' ;
1515export const SHEBANG_REGEX : RegExp = / # ! .* [ \s \n \r ] * / ;
1616export const REACT_DIRECTIVE_REGEX : RegExp =
17- / ^ [ ' " ] u s e ( c l i e n t | s e r v e r ) [ ' " ] ( ; ? ) $ / ;
17+ / ^ [ ' " ] u s e ( c l i e n t | s e r v e r ) [ ' " ] ( ; ? ) [ \s \n \r ] * $ / ;
1818
1919export const JS_EXTENSIONS : string [ ] = [
2020 'js' ,
Original file line number Diff line number Diff line change 11import { createRequire } from 'node:module' ;
2+ import os from 'node:os' ;
23import {
34 type RsbuildConfig ,
45 type RsbuildPlugin ,
@@ -17,7 +18,7 @@ const require = createRequire(import.meta.url);
1718const PLUGIN_NAME = 'rsbuild:entry' ;
1819
1920const 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 ) ;
Original file line number Diff line number Diff line change 1+ import os from 'node:os' ;
12import type { LoaderDefinition } from '@rspack/core' ;
23import {
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 }
Original file line number Diff line number Diff 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 ] ) => {
You can’t perform that action at this time.
0 commit comments