Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
260 changes: 160 additions & 100 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions rspack/collect-typescript-info/src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "rspack build"
},
"devDependencies": {
"@rspack/cli": "1.4.11",
"@rspack/core": "1.4.11"
"@rspack/cli": "1.5.0-rc.0",
"@rspack/core": "1.5.0-rc.0"
}
}
46 changes: 46 additions & 0 deletions rspack/inline-const-enum/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// @ts-check

/** @type {import("@rspack/core").Configuration} */
export default {
entry: {
main: "./src/index.ts",
},
experiments: {
inlineEnum: true,
},
mode: "production",
optimization: {
// disable minimize so you can understand the output
minimize: false,
},
resolve: {
extensions: [".ts", "..."],
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: "builtin:swc-loader",
/** @type {import("@rspack/core").SwcLoaderOptions} */
options: {
jsc: {
parser: {
syntax: "typescript",
},
transform: {
tsEnumIsMutable: true,
}
},
rspackExperiments: {
collectTypeScriptInfo: {
exportedEnum: 'const-only',
}
}
},
},
type: "javascript/auto",
},
],
},
};
9 changes: 9 additions & 0 deletions rspack/inline-const-enum/src/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export enum Kind {
A,
B,
}

export const enum ConstKind {
A,
B,
}
7 changes: 7 additions & 0 deletions rspack/inline-const-enum/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Kind, ConstKind } from './enums';

// Take a look at the build output (dist/main.js)
// Should not inline Kind.A and Kind.B here since inlineEnum is configured to 'const-only'.
console.log(Kind.A, Kind.B);
// Should inline ConstKind.A to 0 and ConstKind.B to 1 here since inlineEnum is configured to 'const-only'.
console.log(ConstKind.A, ConstKind.B);
4 changes: 2 additions & 2 deletions rspack/inline-const/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "rspack build"
},
"devDependencies": {
"@rspack/cli": "1.5.0-beta.0",
"@rspack/core": "1.5.0-beta.0"
"@rspack/cli": "1.5.0-rc.0",
"@rspack/core": "1.5.0-rc.0"
}
}
14 changes: 14 additions & 0 deletions rspack/inline-enum/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "example-builtin-swc-loader",
"version": "1.0.0",
"private": true,
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "rspack build"
},
"devDependencies": {
"@rspack/cli": "1.5.0-rc.0",
"@rspack/core": "1.5.0-rc.0"
}
}
43 changes: 43 additions & 0 deletions rspack/inline-enum/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @ts-check

/** @type {import("@rspack/core").Configuration} */
export default {
entry: {
main: "./src/index.ts",
},
experiments: {
inlineEnum: true,
},
mode: "production",
optimization: {
// disable minimize so you can understand the output
minimize: false,
},
resolve: {
extensions: [".ts", "..."],
},
module: {
rules: [
{
test: /\.ts$/,
use: {
loader: "builtin:swc-loader",
/** @type {import("@rspack/core").SwcLoaderOptions} */
options: {
jsc: {
parser: {
syntax: "typescript",
}
},
rspackExperiments: {
collectTypeScriptInfo: {
exportedEnum: true,
}
}
},
},
type: "javascript/auto",
},
],
},
};
5 changes: 5 additions & 0 deletions rspack/inline-enum/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Kind } from './enums';

// Take a look at the build output (dist/main.js)
// Should inline Kind.A to 0 and Kind.B to 1 here since inlineEnum is configured.
console.log(Kind.A, Kind.B);
14 changes: 14 additions & 0 deletions rspack/type-reexports-presence/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "example-builtin-swc-loader",
"version": "1.0.0",
"private": true,
"license": "MIT",
"main": "index.js",
"scripts": {
"build": "rspack build"
},
"devDependencies": {
"@rspack/cli": "1.5.0-rc.0",
"@rspack/core": "1.5.0-rc.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export default {
main: "./src/index.ts",
},
experiments: {
css: true,
inlineEnum: true,
typeReexportsPresence: true,
},
mode: "production",
Expand All @@ -21,7 +19,7 @@ export default {
module: {
parser: {
javascript: {
typeReexportsPresence: "tolerant"
typeReexportsPresence: "tolerant",
}
},
rules: [
Expand All @@ -34,12 +32,11 @@ export default {
jsc: {
parser: {
syntax: "typescript",
},
}
},
rspackExperiments: {
collectTypeScriptInfo: {
typeExports: true,
exportedEnum: true,
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions rspack/type-reexports-presence/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { TypeA, TypeB } from './reexports';

const a: TypeA = 42;
const b: TypeB = 'rspack';

console.log(a, b);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export * from './enums';

// Should not report ESModulesLinkingWarning since we configured `typeReexportsPresence: "tolerant"`
// case 1:
export { TypeA } from './types';
Expand Down