Skip to content

Commit 6102324

Browse files
committed
feat: add example for collect typescript info
1 parent 60ec319 commit 6102324

File tree

7 files changed

+85
-0
lines changed

7 files changed

+85
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.swc
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "example-builtin-swc-loader",
3+
"version": "1.0.0",
4+
"private": true,
5+
"license": "MIT",
6+
"main": "index.js",
7+
"scripts": {
8+
"build": "rspack build"
9+
},
10+
"devDependencies": {
11+
"@rspack-canary/cli": "1.4.0-canary-30c614aa-20250626094549",
12+
"@rspack-canary/core": "1.4.0-canary-30c614aa-20250626094549"
13+
}
14+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// @ts-check
2+
3+
/** @type {import("@rspack-canary/core").Configuration} */
4+
export default {
5+
entry: {
6+
main: "./src/index.ts",
7+
},
8+
experiments: {
9+
css: true,
10+
inlineEnum: true,
11+
typeReexportsPresence: true,
12+
},
13+
mode: "production",
14+
optimization: {
15+
// disable minimize so you can understand the output
16+
minimize: false,
17+
},
18+
resolve: {
19+
extensions: [".ts", "..."],
20+
},
21+
module: {
22+
parser: {
23+
javascript: {
24+
typeReexportsPresence: "tolerant"
25+
}
26+
},
27+
rules: [
28+
{
29+
test: /\.ts$/,
30+
use: {
31+
loader: "builtin:swc-loader",
32+
/** @type {import("@rspack-canary/core").SwcLoaderOptions} */
33+
options: {
34+
jsc: {
35+
parser: {
36+
syntax: "typescript",
37+
},
38+
},
39+
rspackExperiments: {
40+
collectTypeScriptInfo: {
41+
typeExports: true,
42+
exportedEnum: true,
43+
}
44+
}
45+
},
46+
},
47+
type: "javascript/auto",
48+
},
49+
],
50+
},
51+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum Kind {
2+
A,
3+
B,
4+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Kind, TypeA, TypeB } from './reexports';
2+
3+
const a: TypeA = 42;
4+
const b: TypeB = 'rspack';
5+
6+
console.log(Kind.A, Kind.B, a, b);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export * from './enums';
2+
3+
// typeReexportsPresence case 1:
4+
export { TypeA } from './types';
5+
// typeReexportsPresence case 2:
6+
import { TypeB } from './types';
7+
export { TypeB };
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export type TypeA = number;
2+
export type TypeB = string;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy