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
454 changes: 254 additions & 200 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions rspack/collect-typescript-info/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-canary/cli": "1.4.0-canary-30c614aa-20250626094549",
"@rspack-canary/core": "1.4.0-canary-30c614aa-20250626094549"
}
}
51 changes: 51 additions & 0 deletions rspack/collect-typescript-info/rspack.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// @ts-check

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

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

console.log(a, b);

// Take a look at the build output (dist/main.js)
// Should inline Kind.A to 0 and Kind.B to 1 here since we configured inlineEnum
console.log(Kind.A, Kind.B);
8 changes: 8 additions & 0 deletions rspack/collect-typescript-info/src/reexports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './enums';

// Should not report ESModulesLinkingWarning since we configured `typeReexportsPresence: "tolerant"`
// case 1:
export { TypeA } from './types';
// case 2:
import { TypeB } from './types';
export { TypeB };
2 changes: 2 additions & 0 deletions rspack/collect-typescript-info/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export type TypeA = number;
export type TypeB = string;