Skip to content

Commit d021a36

Browse files
committed
test use strict
1 parent 4a7c331 commit d021a36

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

packages/core/src/plugins/EntryChunkPlugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class EntryChunkPlugin {
126126
replaceSource.replace(
127127
0,
128128
11, // 'use strict;'.length,
129-
`"use strict";${os.EOL}${importMetaUrlShim}`,
129+
`"use strict";\n${importMetaUrlShim}`,
130130
);
131131
} else {
132132
replaceSource.insert(0, importMetaUrlShim);
@@ -154,13 +154,13 @@ class EntryChunkPlugin {
154154
const replaceSource = new rspack.sources.ReplaceSource(old);
155155
// Shebang
156156
if (shebangValue) {
157-
replaceSource.insert(0, `${shebangValue}${os.EOL}`);
157+
replaceSource.insert(0, `${shebangValue}\n`);
158158
this.shebangInjectedAssets.add(name);
159159
}
160160

161161
// React directives
162162
if (reactDirectiveValue) {
163-
replaceSource.insert(0, `${reactDirectiveValue}${os.EOL}`);
163+
replaceSource.insert(0, `${reactDirectiveValue}\n`);
164164
}
165165

166166
return replaceSource;

pnpm-lock.yaml

Lines changed: 4 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/shims/index.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os from 'node:os';
12
import path, { join } from 'node:path';
23
import { pathToFileURL } from 'node:url';
34
import vm from 'node:vm';
@@ -95,10 +96,12 @@ describe('CJS shims', () => {
9596
const fileUrl = pathToFileURL(entryFiles.cjs).href;
9697
expect(importMetaUrl).toBe(fileUrl);
9798
expect(requiredModule).toBe('ok');
98-
expect(cjsCode.startsWith('"use strict"')).toBe(true);
99-
expect(cjsCode).toContain(
100-
'const __rslib_import_meta_url__ = /*#__PURE__*/ function() {',
101-
);
99+
console.log('🤦‍♀️', cjsCode);
100+
expect(
101+
cjsCode.startsWith(
102+
`"use strict";\nconst __rslib_import_meta_url__ = /*#__PURE__*/ function() {`,
103+
),
104+
).toBe(true);
102105
});
103106

104107
test('ESM should not be affected by CJS shims configuration', async () => {

0 commit comments

Comments
 (0)