Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/core/tests/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
experiments: {
lazyBarrel: true,
inlineEnum: true,
inlineConst: true,
typeReexportsPresence: true,
rspackFuture: {
bundlerInfo: {
Expand Down Expand Up @@ -455,6 +456,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
module: {
parser: {
javascript: {
inlineConst: true,
exportsPresence: 'error',
typeReexportsPresence: 'tolerant',
importMeta: false,
Expand Down Expand Up @@ -1009,6 +1011,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
experiments: {
lazyBarrel: true,
inlineEnum: true,
inlineConst: true,
typeReexportsPresence: true,
rspackFuture: {
bundlerInfo: {
Expand Down Expand Up @@ -1151,6 +1154,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
module: {
parser: {
javascript: {
inlineConst: true,
exportsPresence: 'error',
typeReexportsPresence: 'tolerant',
importMeta: false,
Expand Down Expand Up @@ -1701,6 +1705,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
experiments: {
lazyBarrel: true,
inlineEnum: true,
inlineConst: true,
typeReexportsPresence: true,
rspackFuture: {
bundlerInfo: {
Expand Down Expand Up @@ -1830,6 +1835,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
module: {
parser: {
javascript: {
inlineConst: true,
exportsPresence: 'error',
typeReexportsPresence: 'tolerant',
importMeta: false
Expand Down Expand Up @@ -2299,6 +2305,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
experiments: {
lazyBarrel: true,
inlineEnum: true,
inlineConst: true,
typeReexportsPresence: true,
rspackFuture: {
bundlerInfo: {
Expand Down Expand Up @@ -2430,6 +2437,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
module: {
parser: {
javascript: {
inlineConst: true,
exportsPresence: 'error',
typeReexportsPresence: 'tolerant',
importMeta: false
Expand Down Expand Up @@ -2898,6 +2906,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
experiments: {
lazyBarrel: true,
inlineEnum: true,
inlineConst: true,
typeReexportsPresence: true,
rspackFuture: {
bundlerInfo: {
Expand Down Expand Up @@ -2966,6 +2975,7 @@ exports[`Should compose create Rsbuild config correctly > Merge Rsbuild config i
module: {
parser: {
javascript: {
inlineConst: true,
exportsPresence: 'error',
typeReexportsPresence: 'tolerant'
}
Expand Down
1 change: 1 addition & 0 deletions rslint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/switch-exhaustiveness-check": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
]
12 changes: 6 additions & 6 deletions tests/integration/auto-extension/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ describe('should respect output.filename.js and output.filenameHash to override
// override output.filename.js
expect(extname(entryFiles.esm0!)).toEqual('.mjs');
expect(entryFiles.cjs0).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/cjs-override-filename/index.df02628a.js"`,
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/cjs-override-filename/index.c8a12fd0.js"`,
);

// override output.filenameHash
expect(entryFiles.esm1).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/esm-override-filename-hash/index.996a7edd.js"`,
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/esm-override-filename-hash/index.b4545719.js"`,
);
expect(entryFiles.cjs1).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/cjs-override-filename-hash/index.df02628a.js"`,
`"<ROOT>/tests/integration/auto-extension/type-commonjs/config-override/dist/cjs-override-filename-hash/index.c8a12fd0.js"`,
);

// override different file types with function
Expand All @@ -80,16 +80,16 @@ describe('should respect output.filename.js and output.filenameHash to override

// override output.filename.js
expect(entryFiles.esm0).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/esm-override-filename/index.996a7edd.js"`,
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/esm-override-filename/index.b4545719.js"`,
);
expect(extname(entryFiles.cjs0!)).toEqual('.cjs');

// override output.filenameHash
expect(entryFiles.esm1).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/esm-override-filename-hash/index.996a7edd.js"`,
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/esm-override-filename-hash/index.b4545719.js"`,
);
expect(entryFiles.cjs1).toMatchInlineSnapshot(
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/cjs-override-filename-hash/index.df02628a.js"`,
`"<ROOT>/tests/integration/auto-extension/type-module/config-override/dist/cjs-override-filename-hash/index.c8a12fd0.js"`,
);

// override different file types with function
Expand Down
12 changes: 7 additions & 5 deletions tests/integration/entry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,25 @@ test('multiple entry bundle', async () => {
const { content: index } = queryContent(contents.esm, 'index.js', {
basename: true,
});
// cspell:disable
expect(index).toMatchInlineSnapshot(`
"const shared = 'shared';
const foo = 'foo' + shared;
const src_text = ()=>\`hello \${foo} \${shared}\`;
"const foo = "fooshared";
const src_text = ()=>\`hello \${foo} shared\`;
export { src_text as text };
"
`);
// cspell:enable

const { content: foo } = queryContent(contents.esm, 'foo.js', {
basename: true,
});
// cspell:disable
expect(foo).toMatchInlineSnapshot(`
"const shared = 'shared';
const foo = 'foo' + shared;
"const foo = "fooshared";
export { foo };
"
`);
// cspell:enable

const { content: shared } = queryContent(contents.esm, 'shared.js', {
basename: true,
Expand Down
20 changes: 14 additions & 6 deletions tests/integration/extension-alias/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

exports[`resolve.extensionAlias should work 1`] = `
""use strict";
var __webpack_require__ = {};
(()=>{
__webpack_require__.r = (exports1)=>{
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
const bar = 'bar';
const foo = 'foo';
console.log(foo + bar);
__webpack_require__.r(__webpack_exports__);
console.log("foobar");
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
value: true
Expand All @@ -14,8 +24,6 @@ Object.defineProperty(exports, '__esModule', {
`;

exports[`resolve.extensionAlias should work 2`] = `
"const bar = 'bar';
const foo = 'foo';
console.log(foo + bar);
"console.log("foobar");
"
`;
3 changes: 1 addition & 2 deletions tests/integration/externals/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ test('user externals', async () => {
"import node_fs from "node:fs";
import lodash from "lodash";
import zip from "lodash/zip";
const foo = 'foo';
console.log(node_fs, lodash.add, zip, foo);
console.log(node_fs, lodash.add, zip, "foo");
"
`,
);
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/format/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ test('format default to esm', async () => {
}
`);

// cspell:disable
expect(contents.esm0).toMatchInlineSnapshot(`
{
"<ROOT>/tests/integration/format/default/dist/bundle-esm/index.js": "const foo = 'foo';
const str = 'hello' + foo + ' world';
"<ROOT>/tests/integration/format/default/dist/bundle-esm/index.js": "const str = "hellofoo world";
export { str };
",
}
`);
// cspell:enable

expect(contents.esm1).toMatchInlineSnapshot(`
{
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/require/import-dynamic/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const i1 = import(`${process.env.DIR}./other`);
const i2 = import(process.env.DIR!);
const condition = 1 > 0;
const condition = process.env.CONDITION === '1';
const i3 = import(condition ? './other1' : './other2');
export { i1, i2, i3 };
6 changes: 2 additions & 4 deletions tests/integration/resolve/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ test('resolve with js extensions', async () => {

expect(isSuccess).toBeTruthy();
expect(entries.esm).toMatchInlineSnapshot(`
"const value = 1;
console.log(value);
"console.log(1);
"
`);
});
Expand All @@ -76,8 +75,7 @@ test('resolve with main fields', async () => {

expect(isSuccess).toBeTruthy();
expect(Object.values(results[0]!)[0]).toMatchInlineSnapshot(`
"const value = 1;
console.log(value);
"console.log(1);
"
`);
expect(Object.values(results[1]!)[0]).toContain('main');
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/tsconfig/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ test('tsconfig path', async () => {
const { isSuccess, entries } = await buildAndGetResults({ fixturePath });

expect(isSuccess).toBe(true);
expect(entries.esm).toContain(`const foo = 'foo'`);
expect(entries.cjs).toContain(`const foo = 'foo'`);
expect(entries.esm).toContain(`console.info("foo");
`);
expect(entries.cjs).toContain(`console.info("foo");
`);
});
Loading