-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathrsbuild.config.ts
More file actions
76 lines (74 loc) · 2.95 KB
/
Copy pathrsbuild.config.ts
File metadata and controls
76 lines (74 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { defineConfig } from '@rsbuild/core';
import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill';
const MAX_BUNDLE_BYTES = 350 * 1024;
// eslint-disable-next-line import/no-default-export
export default defineConfig({
source: {
entry: {
Apify: './src/index.ts',
},
},
resolve: {
alias: {
// The `imports` field of `package.json` maps this to `dist`; bundle the source instead.
'#runtime': './src/runtime/web.ts',
},
// `tsconfig.json` maps `#runtime` to the Node.js implementation for type-checking, and the default
// strategy lets that mapping win over the alias.
aliasStrategy: 'prefer-alias',
},
output: {
distPath: { js: '.' },
filename: { js: 'bundle.js' },
// filename: { js: '[name].js' },
target: 'web',
cleanDistPath: false,
sourceMap: true,
minify: {
jsOptions: {
minimizerOptions: {
// Class names are load-bearing: `ApifyApiError` and `InvalidResponseBodyError` take
// their `name` from `constructor.name`, and `ResourceClient.waitForFinish()` parses
// the client name out of it.
compress: { keep_classnames: true },
mangle: { keep_classnames: true },
},
},
},
},
tools: {
htmlPlugin: false,
rspack(config) {
config.output = {
...config.output,
module: true,
library: { type: 'module' },
asyncChunks: false,
};
config.experiments = {
...config.experiments,
outputModule: true,
};
config.optimization = {
...config.optimization,
splitChunks: false,
};
// A regression guard, not a target: the bundle sits at ~325 kB, so this only fails the
// build on an unnoticed jump. A `zod` minor is the likeliest cause, since it is a runtime
// dependency on a caret range - bumping this constant is the expected response. The
// generated response schemas growing with the OpenAPI specification is the other.
config.performance = {
hints: 'error',
maxAssetSize: MAX_BUNDLE_BYTES,
maxEntrypointSize: MAX_BUNDLE_BYTES,
// The source map is many times the size of the bundle and ships separately.
assetFilter: (filename) => filename === 'bundle.js',
};
config.devtool = 'source-map';
},
},
mode: 'production',
// The client's own code needs no polyfills, so these cover its dependencies. `node:crypto` is excluded,
// because the client only calls the helpers built on Web Crypto.
plugins: [pluginNodePolyfill({ overrides: { crypto: false } })],
});