@bleedingdev/modern-js-builder 3.8.3-ultramodern.1 → 3.8.3-ultramodern.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cjs/createBuilder.js +1 -4
  2. package/dist/cjs/plugins/rscConfig.js +0 -138
  3. package/dist/cjs/shared/parseCommonConfig.js +4 -12
  4. package/dist/esm/createBuilder.mjs +1 -4
  5. package/dist/esm/plugins/rscConfig.mjs +1 -136
  6. package/dist/esm/shared/parseCommonConfig.mjs +4 -12
  7. package/dist/esm-node/createBuilder.mjs +1 -4
  8. package/dist/esm-node/plugins/rscConfig.mjs +1 -136
  9. package/dist/esm-node/shared/parseCommonConfig.mjs +4 -12
  10. package/dist/types/plugins/rscConfig.d.ts +0 -32
  11. package/dist/types/shared/parseCommonConfig.d.ts +0 -2
  12. package/dist/types/types.d.ts +1 -12
  13. package/package.json +5 -6
  14. package/dist/cjs/plugins/environmentBuildCache.js +0 -89
  15. package/dist/cjs/plugins/rsdoctor.js +0 -68
  16. package/dist/cjs/plugins/rspack21.js +0 -57
  17. package/dist/cjs/rsdoctorConfig.js +0 -18
  18. package/dist/cjs/shared/tsgo.js +0 -212
  19. package/dist/esm/plugins/environmentBuildCache.mjs +0 -38
  20. package/dist/esm/plugins/rsdoctor.mjs +0 -30
  21. package/dist/esm/plugins/rspack21.mjs +0 -19
  22. package/dist/esm/rsdoctorConfig.mjs +0 -0
  23. package/dist/esm/shared/tsgo.mjs +0 -160
  24. package/dist/esm-node/plugins/environmentBuildCache.mjs +0 -39
  25. package/dist/esm-node/plugins/rsdoctor.mjs +0 -31
  26. package/dist/esm-node/plugins/rspack21.mjs +0 -20
  27. package/dist/esm-node/rsdoctorConfig.mjs +0 -1
  28. package/dist/esm-node/shared/tsgo.mjs +0 -161
  29. package/dist/types/plugins/environmentBuildCache.d.ts +0 -3
  30. package/dist/types/plugins/rsdoctor.d.ts +0 -3
  31. package/dist/types/plugins/rspack21.d.ts +0 -4
  32. package/dist/types/rsdoctorConfig.d.ts +0 -12
  33. package/dist/types/shared/tsgo.d.ts +0 -12
@@ -1,161 +0,0 @@
1
- import "node:module";
2
- import { createHash } from "node:crypto";
3
- import node_fs from "node:fs";
4
- import { createRequire } from "node:module";
5
- import node_path from "node:path";
6
- import { json5 } from "@modern-js/utils";
7
- const builderRequire = createRequire(import.meta.url);
8
- const STABLE_TSGO_PACKAGE = "typescript/package.json";
9
- const NATIVE_PREVIEW_TSGO_PACKAGE = "@typescript/native-preview/package.json";
10
- const TSGO_CHECKER_DIR = node_path.join('.modern-js', 'tsgo');
11
- const tryResolve = (request, rootPath)=>{
12
- try {
13
- return builderRequire.resolve(request, {
14
- paths: [
15
- rootPath
16
- ]
17
- });
18
- } catch {
19
- return;
20
- }
21
- };
22
- const readPackageMajorVersion = (packageJsonPath)=>{
23
- try {
24
- const packageJson = JSON.parse(node_fs.readFileSync(packageJsonPath, 'utf8'));
25
- const major = Number.parseInt(String(packageJson.version).split('.')[0], 10);
26
- return Number.isFinite(major) ? major : void 0;
27
- } catch {
28
- return;
29
- }
30
- };
31
- const resolveTsgoPackagePath = (rootPath)=>{
32
- const stableTypeScriptPath = tryResolve(STABLE_TSGO_PACKAGE, rootPath);
33
- if (stableTypeScriptPath && (readPackageMajorVersion(stableTypeScriptPath) ?? 0) >= 7) return stableTypeScriptPath;
34
- return tryResolve(NATIVE_PREVIEW_TSGO_PACKAGE, rootPath) ?? builderRequire.resolve(NATIVE_PREVIEW_TSGO_PACKAGE);
35
- };
36
- const toPosixPath = (input)=>input.replaceAll(node_path.sep, '/');
37
- const asTsConfigPath = (request)=>{
38
- if (node_path.extname(request)) return [
39
- request
40
- ];
41
- return [
42
- request,
43
- `${request}.json`
44
- ];
45
- };
46
- const resolveExtends = (request, configDirectory)=>{
47
- const configRequire = createRequire(node_path.join(configDirectory, 'tsconfig.json'));
48
- for (const candidate of asTsConfigPath(request)){
49
- if (candidate.startsWith('.') || node_path.isAbsolute(candidate)) {
50
- const resolved = node_path.resolve(configDirectory, candidate);
51
- if (node_fs.existsSync(resolved)) return resolved;
52
- continue;
53
- }
54
- try {
55
- return configRequire.resolve(candidate);
56
- } catch {}
57
- }
58
- };
59
- const readTsConfig = (configFile, visited = new Set())=>{
60
- if (visited.has(configFile) || !node_fs.existsSync(configFile)) return {};
61
- visited.add(configFile);
62
- const config = json5.parse(node_fs.readFileSync(configFile, 'utf8'));
63
- const configDirectory = node_path.dirname(configFile);
64
- const extendsList = Array.isArray(config.extends) ? config.extends : config.extends ? [
65
- config.extends
66
- ] : [];
67
- const baseConfig = extendsList.reduce((merged, request)=>{
68
- const resolved = resolveExtends(request, configDirectory);
69
- if (!resolved) return merged;
70
- const parentConfig = readTsConfig(resolved, visited);
71
- return {
72
- ...merged,
73
- compilerOptions: {
74
- ...merged.compilerOptions ?? {},
75
- ...parentConfig.compilerOptions ?? {}
76
- }
77
- };
78
- }, {});
79
- return {
80
- ...baseConfig,
81
- compilerOptions: {
82
- ...baseConfig.compilerOptions ?? {},
83
- ...config.compilerOptions ?? {}
84
- }
85
- };
86
- };
87
- const toRelativeConfigPath = (fromDirectory, target)=>{
88
- const relative = toPosixPath(node_path.relative(fromDirectory, target));
89
- if (relative.startsWith('.')) return relative;
90
- return `./${relative}`;
91
- };
92
- const writeFileIfChanged = (file, content)=>{
93
- if (node_fs.existsSync(file) && node_fs.readFileSync(file, 'utf8') === content) return;
94
- node_fs.writeFileSync(file, content);
95
- };
96
- const createTsgoCheckerConfig = (configFile)=>{
97
- const configDirectory = node_path.dirname(configFile);
98
- const checkerConfigDirectory = node_path.join(configDirectory, TSGO_CHECKER_DIR);
99
- const hash = createHash('sha1').update(configFile).digest('hex').slice(0, 10);
100
- const checkerConfigFile = node_path.join(checkerConfigDirectory, `tsconfig.${hash}.json`);
101
- const tsConfig = readTsConfig(configFile);
102
- const compilerOptions = {
103
- baseUrl: null
104
- };
105
- const moduleResolution = String(tsConfig.compilerOptions?.moduleResolution).toLowerCase();
106
- if ([
107
- 'node',
108
- 'node10'
109
- ].includes(moduleResolution)) compilerOptions.moduleResolution = null;
110
- const checkerConfig = {
111
- extends: toRelativeConfigPath(checkerConfigDirectory, configFile),
112
- compilerOptions
113
- };
114
- node_fs.mkdirSync(checkerConfigDirectory, {
115
- recursive: true
116
- });
117
- writeFileIfChanged(checkerConfigFile, `${JSON.stringify(checkerConfig, null, 2)}\n`);
118
- return checkerConfigFile;
119
- };
120
- const normalizeTsgoConfig = (config, rootPath)=>{
121
- const { typescript } = config;
122
- if (typescript?.tsgo === false) return config;
123
- const compilerOptions = {
124
- ...typescript?.configOverwrite?.compilerOptions ?? {},
125
- baseUrl: null
126
- };
127
- if ([
128
- 'node',
129
- 'node10'
130
- ].includes(String(compilerOptions.moduleResolution).toLowerCase())) compilerOptions.moduleResolution = null;
131
- config.typescript = {
132
- ...typescript,
133
- configOverwrite: {
134
- ...typescript?.configOverwrite ?? {},
135
- compilerOptions
136
- }
137
- };
138
- if (typescript?.configFile) config.typescript.configFile = createTsgoCheckerConfig(node_path.resolve(rootPath, typescript.configFile));
139
- return config;
140
- };
141
- const withTsgoDefaults = (userOptions, rootPath)=>{
142
- const tsgoPath = resolveTsgoPackagePath(rootPath);
143
- const userChain = userOptions ? Array.isArray(userOptions) ? userOptions : [
144
- userOptions
145
- ] : [];
146
- return [
147
- {
148
- typescript: {
149
- tsgo: true,
150
- typescriptPath: tsgoPath
151
- }
152
- },
153
- ...userChain,
154
- (config)=>{
155
- const { typescript } = config;
156
- if (typescript?.tsgo === false && typescript.typescriptPath === tsgoPath) typescript.typescriptPath = tryResolve("typescript", rootPath);
157
- return normalizeTsgoConfig(config, rootPath);
158
- }
159
- ];
160
- };
161
- export { withTsgoDefaults };
@@ -1,3 +0,0 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare function isolateEnvironmentBuildCacheDirectory(cacheDirectory: string | undefined, environmentName: string): string;
3
- export declare const pluginEnvironmentBuildCacheIsolation: () => RsbuildPlugin;
@@ -1,3 +0,0 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- import type { RsdoctorUserConfig } from '../rsdoctorConfig';
3
- export declare const pluginRsdoctor: (config: RsdoctorUserConfig | undefined) => RsbuildPlugin | null;
@@ -1,4 +0,0 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare const pluginRspack21: ({ sourceImport, }?: {
3
- sourceImport?: boolean;
4
- }) => RsbuildPlugin;
@@ -1,12 +0,0 @@
1
- export type RsdoctorUserConfig = boolean | {
2
- /**
3
- * Force enable / disable Rsdoctor.
4
- * When `performance.rsdoctor` is not configured, Rsdoctor is disabled.
5
- */
6
- enabled?: boolean;
7
- /**
8
- * Disable Rsdoctor client server and ensure build process exits after report generation.
9
- * @default true
10
- */
11
- disableClientServer?: boolean;
12
- };
@@ -1,12 +0,0 @@
1
- import type { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
2
- type TsCheckerChain = NonNullable<PluginTypeCheckerOptions['tsCheckerOptions']>;
3
- type TsCheckerFn = Extract<TsCheckerChain, (config: never) => unknown>;
4
- export type TsCheckerOptions = Parameters<TsCheckerFn>[0];
5
- /**
6
- * Type checking runs on TypeScript Go (`tsgo`) by default. The checker
7
- * prefers the project's stable TypeScript 7 package, then falls back to
8
- * `@typescript/native-preview` for projects still on the preview lane.
9
- * Set `tools.tsChecker.typescript.tsgo: false` to use the classic checker.
10
- */
11
- export declare const withTsgoDefaults: (userOptions: TsCheckerChain | undefined, rootPath: string) => TsCheckerChain;
12
- export {};