smartbundle 0.12.3 → 0.13.0-alpha.0
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.
- package/__compiled__/cjs/src/PrettyErrors.d.ts +2 -0
- package/__compiled__/cjs/src/PrettyErrors.js +6 -0
- package/__compiled__/cjs/src/PrettyErrors.js.map +1 -0
- package/__compiled__/cjs/src/createViteConfig.d.ts +2 -1
- package/__compiled__/cjs/src/createViteConfig.js +8 -35
- package/__compiled__/cjs/src/createViteConfig.js.map +1 -1
- package/__compiled__/cjs/src/detectModules.d.ts +14 -2
- package/__compiled__/cjs/src/detectModules.js +58 -9
- package/__compiled__/cjs/src/detectModules.js.map +1 -1
- package/__compiled__/cjs/src/index.d.ts +6 -2
- package/__compiled__/cjs/src/index.js +20 -3
- package/__compiled__/cjs/src/index.js.map +1 -1
- package/__compiled__/cjs/src/plugins/babel/index.js +2 -6
- package/__compiled__/cjs/src/plugins/babel/index.js.map +1 -1
- package/__compiled__/cjs/src/plugins/imports/ImportError.d.ts +7 -0
- package/__compiled__/cjs/src/plugins/imports/ImportError.js +35 -0
- package/__compiled__/cjs/src/plugins/imports/ImportError.js.map +1 -0
- package/__compiled__/cjs/src/plugins/imports/index.d.ts +3 -0
- package/__compiled__/cjs/src/plugins/imports/index.js +89 -0
- package/__compiled__/cjs/src/plugins/imports/index.js.map +1 -0
- package/__compiled__/cjs/src/promiseSettledResultErrors.js +1 -1
- package/__compiled__/cjs/src/promiseSettledResultErrors.js.map +1 -1
- package/__compiled__/cjs/src/run.js +13 -4
- package/__compiled__/cjs/src/run.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.d.ts +2 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.js +13 -34
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsNames.d.ts +2 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsNames.js +12 -30
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsNames.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsPackages.d.ts +2 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsPackages.js +13 -13
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsPackages.js.map +1 -1
- package/__compiled__/cjs/src/tasks/viteTask.d.ts +1 -11
- package/__compiled__/cjs/src/tasks/viteTask.js +11 -5
- package/__compiled__/cjs/src/tasks/viteTask.js.map +1 -1
- package/__compiled__/esm/src/PrettyErrors.d.mts +2 -0
- package/__compiled__/esm/src/PrettyErrors.mjs +6 -0
- package/__compiled__/esm/src/PrettyErrors.mjs.map +1 -0
- package/__compiled__/esm/src/createViteConfig.d.mts +2 -1
- package/__compiled__/esm/src/createViteConfig.mjs +4 -31
- package/__compiled__/esm/src/createViteConfig.mjs.map +1 -1
- package/__compiled__/esm/src/detectModules.d.mts +14 -2
- package/__compiled__/esm/src/detectModules.mjs +59 -10
- package/__compiled__/esm/src/detectModules.mjs.map +1 -1
- package/__compiled__/esm/src/index.d.mts +6 -2
- package/__compiled__/esm/src/index.mjs +20 -3
- package/__compiled__/esm/src/index.mjs.map +1 -1
- package/__compiled__/esm/src/plugins/babel/index.mjs +2 -6
- package/__compiled__/esm/src/plugins/babel/index.mjs.map +1 -1
- package/__compiled__/esm/src/plugins/imports/ImportError.d.mts +7 -0
- package/__compiled__/esm/src/plugins/imports/ImportError.mjs +35 -0
- package/__compiled__/esm/src/plugins/imports/ImportError.mjs.map +1 -0
- package/__compiled__/esm/src/plugins/imports/index.d.mts +3 -0
- package/__compiled__/esm/src/plugins/imports/index.mjs +72 -0
- package/__compiled__/esm/src/plugins/imports/index.mjs.map +1 -0
- package/__compiled__/esm/src/promiseSettledResultErrors.mjs +1 -1
- package/__compiled__/esm/src/promiseSettledResultErrors.mjs.map +1 -1
- package/__compiled__/esm/src/run.mjs +13 -4
- package/__compiled__/esm/src/run.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.d.mts +2 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.mjs +13 -34
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsNames.d.mts +2 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsNames.mjs +3 -4
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsNames.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsPackages.d.mts +2 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsPackages.mjs +5 -4
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsPackages.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/viteTask.d.mts +1 -11
- package/__compiled__/esm/src/tasks/viteTask.mjs +11 -5
- package/__compiled__/esm/src/tasks/viteTask.mjs.map +1 -1
- package/package.json +2 -1
@@ -1,7 +1,8 @@
|
|
1
1
|
import { type PackageJson } from "../../packageJson.js";
|
2
|
+
import { type TS } from "../../detectModules.js";
|
2
3
|
import { type Dirs } from "../../resolveDirs.js";
|
3
4
|
type BuildTypesOptions = {
|
4
|
-
ts:
|
5
|
+
ts: TS;
|
5
6
|
dirs: Dirs;
|
6
7
|
packageJson: PackageJson;
|
7
8
|
tsEntrypoints: string[];
|
@@ -41,40 +41,12 @@ async function callTypescript({
|
|
41
41
|
packageJson
|
42
42
|
}) {
|
43
43
|
const { sourceDir, outDir, esmOutDir, cjsOutDir } = dirs;
|
44
|
-
const configPath = path__namespace.join(sourceDir, "tsconfig.json");
|
45
|
-
const configFile = ts.readConfigFile(
|
46
|
-
configPath,
|
47
|
-
(path2) => (
|
48
|
-
// https://github.com/XaveScor/bobrik/issues/22
|
49
|
-
fs__namespace.readFileSync(path2, "utf-8")
|
50
|
-
)
|
51
|
-
);
|
52
|
-
const parsedCommandLine = ts.parseJsonConfigFileContent(
|
53
|
-
configFile.config,
|
54
|
-
ts.sys,
|
55
|
-
sourceDir,
|
56
|
-
{
|
57
|
-
declaration: true,
|
58
|
-
emitDeclarationOnly: true,
|
59
|
-
strict: false,
|
60
|
-
strictNullChecks: false,
|
61
|
-
strictFunctionTypes: false,
|
62
|
-
strictPropertyInitialization: false,
|
63
|
-
skipLibCheck: true,
|
64
|
-
skipDefaultLibCheck: true,
|
65
|
-
outDir: "",
|
66
|
-
// https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352
|
67
|
-
noEmit: false
|
68
|
-
},
|
69
|
-
configPath
|
70
|
-
);
|
71
|
-
const host = ts.createCompilerHost(parsedCommandLine.options);
|
72
44
|
const sourceToCjsDtsMap = /* @__PURE__ */ new Map();
|
73
45
|
const sourceToEsmDtsMap = /* @__PURE__ */ new Map();
|
74
|
-
const program = ts.createProgram(
|
46
|
+
const program = ts.ts.createProgram(
|
75
47
|
tsEntrypoints,
|
76
|
-
|
77
|
-
host
|
48
|
+
ts.parsedConfig.options,
|
49
|
+
ts.host
|
78
50
|
);
|
79
51
|
program.emit(void 0, (fileName, data) => {
|
80
52
|
const relativePath = path__namespace.relative(sourceDir, fileName);
|
@@ -98,7 +70,7 @@ async function callTypescript({
|
|
98
70
|
const relativePath = path__namespace.relative(outDir, file);
|
99
71
|
if (file.endsWith(".d.ts")) {
|
100
72
|
const transformedCode = inlineExtensions.inlineExtensionsCjs(
|
101
|
-
ts,
|
73
|
+
ts.ts,
|
102
74
|
content,
|
103
75
|
makeFileExists(outDir, relativePath)
|
104
76
|
);
|
@@ -106,7 +78,7 @@ async function callTypescript({
|
|
106
78
|
}
|
107
79
|
if (file.endsWith(".d.mts")) {
|
108
80
|
const transformedCode = inlineExtensions.inlineExtensionsMjs(
|
109
|
-
ts,
|
81
|
+
ts.ts,
|
110
82
|
content,
|
111
83
|
makeFileExists(outDir, relativePath)
|
112
84
|
);
|
@@ -118,6 +90,7 @@ async function callTypescript({
|
|
118
90
|
const esmEntrypoint = sourceToEsmDtsMap.get(sourceEntrypoint);
|
119
91
|
if (esmEntrypoint) {
|
120
92
|
const localPackages = findTypingsNames.findTypingsNames(
|
93
|
+
ts,
|
121
94
|
esmEntrypoint,
|
122
95
|
esmOutDir,
|
123
96
|
".d.mts"
|
@@ -128,13 +101,19 @@ async function callTypescript({
|
|
128
101
|
}
|
129
102
|
const cjsEntrypoint = sourceToCjsDtsMap.get(sourceEntrypoint);
|
130
103
|
if (cjsEntrypoint) {
|
131
|
-
const localPackages = findTypingsNames.findTypingsNames(
|
104
|
+
const localPackages = findTypingsNames.findTypingsNames(
|
105
|
+
ts,
|
106
|
+
cjsEntrypoint,
|
107
|
+
cjsOutDir,
|
108
|
+
".d.ts"
|
109
|
+
);
|
132
110
|
for (const p of localPackages) {
|
133
111
|
packages.add(p);
|
134
112
|
}
|
135
113
|
}
|
136
114
|
}
|
137
115
|
const { missingTypings, existingTypingPackages } = findTypingsPackages.findTypingsPackages(
|
116
|
+
ts,
|
138
117
|
packages,
|
139
118
|
sourceDir
|
140
119
|
);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"callTypescript.js","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport {\n inlineExtensionsMjs,\n inlineExtensionsCjs,\n} from \"./inlineExtensions.js\";\nimport { type PackageJson } from \"../../packageJson.js\";\nimport { getMinVersion } from \"../../detectModules.js\";\nimport { BuildError } from \"../../error.js\";\nimport { findTypingsPackages } from \"./findTypingsPackages.js\";\nimport { findTypingsNames } from \"./findTypingsNames.js\";\nimport { type Dirs } from \"../../resolveDirs.js\";\n\ntype BuildTypesOptions = {\n ts:
|
1
|
+
{"version":3,"file":"callTypescript.js","sources":["../../../../../../src/tasks/buildTypesTask/callTypescript.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport * as fs from \"node:fs\";\nimport {\n inlineExtensionsMjs,\n inlineExtensionsCjs,\n} from \"./inlineExtensions.js\";\nimport { type PackageJson } from \"../../packageJson.js\";\nimport { getMinVersion, type TS } from \"../../detectModules.js\";\nimport { BuildError } from \"../../error.js\";\nimport { findTypingsPackages } from \"./findTypingsPackages.js\";\nimport { findTypingsNames } from \"./findTypingsNames.js\";\nimport { type Dirs } from \"../../resolveDirs.js\";\n\ntype BuildTypesOptions = {\n ts: TS;\n dirs: Dirs;\n packageJson: PackageJson;\n tsEntrypoints: string[];\n outDir: string;\n};\n\nfunction makeFileExists(outDir: string, filePath: string) {\n return (p: string) => {\n const dir = path.join(outDir, path.dirname(filePath));\n return fs.existsSync(path.join(dir, p));\n };\n}\n\nexport async function callTypescript({\n ts,\n dirs,\n tsEntrypoints,\n packageJson,\n}: BuildTypesOptions) {\n const { sourceDir, outDir, esmOutDir, cjsOutDir } = dirs;\n\n // <build d.ts>\n const sourceToCjsDtsMap = new Map<string, string>();\n const sourceToEsmDtsMap = new Map<string, string>();\n const program = ts.ts.createProgram(\n tsEntrypoints,\n ts.parsedConfig.options,\n ts.host,\n );\n program.emit(undefined, (fileName, data) => {\n // .d.ts for cjs because \"type\": \"commonjs\" in package.json\n // .d.mts for esm\n const relativePath = path.relative(sourceDir, fileName);\n const sourceFileName = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n\n const finalEsmPath = path.join(esmOutDir, relativePath);\n const esmFinalPath = finalEsmPath.replace(/\\.d\\.ts$/, \".d.mts\");\n sourceToEsmDtsMap.set(sourceFileName, esmFinalPath);\n fs.mkdirSync(path.dirname(esmFinalPath), { recursive: true });\n fs.writeFileSync(esmFinalPath, data);\n\n const finalCjsPath = path.join(cjsOutDir, relativePath);\n fs.mkdirSync(path.dirname(finalCjsPath), { recursive: true });\n const cjsFinalPath = finalCjsPath;\n fs.writeFileSync(cjsFinalPath, data);\n sourceToCjsDtsMap.set(sourceFileName, cjsFinalPath);\n });\n // </build d.ts>\n\n // <fix vscode typings>\n for (const file of [\n ...sourceToCjsDtsMap.values(),\n ...sourceToEsmDtsMap.values(),\n ]) {\n const content = fs.readFileSync(file, \"utf-8\");\n const relativePath = path.relative(outDir, file);\n if (file.endsWith(\".d.ts\")) {\n const transformedCode = inlineExtensionsCjs(\n ts.ts,\n content,\n makeFileExists(outDir, relativePath),\n );\n fs.writeFileSync(file, transformedCode);\n }\n if (file.endsWith(\".d.mts\")) {\n const transformedCode = inlineExtensionsMjs(\n ts.ts,\n content,\n makeFileExists(outDir, relativePath),\n );\n fs.writeFileSync(file, transformedCode);\n }\n }\n // </fix vscode typings>\n\n // <find all libraries names>\n const packages = new Set<string>();\n for (const sourceEntrypoint of tsEntrypoints) {\n const esmEntrypoint = sourceToEsmDtsMap.get(sourceEntrypoint);\n if (esmEntrypoint) {\n const localPackages = findTypingsNames(\n ts,\n esmEntrypoint,\n esmOutDir,\n \".d.mts\",\n );\n for (const p of localPackages) {\n packages.add(p);\n }\n }\n\n const cjsEntrypoint = sourceToCjsDtsMap.get(sourceEntrypoint);\n if (cjsEntrypoint) {\n const localPackages = findTypingsNames(\n ts,\n cjsEntrypoint,\n cjsOutDir,\n \".d.ts\",\n );\n for (const p of localPackages) {\n packages.add(p);\n }\n }\n }\n // </find all libraries names>\n\n // <check not installed typings libraries>\n const { missingTypings, existingTypingPackages } = findTypingsPackages(\n ts,\n packages,\n sourceDir,\n );\n for (const lib of existingTypingPackages) {\n if (\n getMinVersion(packageJson, lib, [\n \"optionalDependencies\",\n \"devDependencies\",\n ]) == null\n ) {\n missingTypings.add(lib);\n }\n }\n if (missingTypings.size > 0) {\n const libsList = [...missingTypings].map((x) => `\"${x}\"`).join(\", \");\n throw new BuildError(\n `The typings won't installed in bundled package: ${libsList}. Please install them into dependencies or peerDependencies.`,\n );\n }\n // </check not installed typings libraries>\n\n return {\n sourceToCjsDtsMap,\n sourceToEsmDtsMap,\n };\n}\n"],"names":["path","fs","inlineExtensionsCjs","inlineExtensionsMjs","findTypingsNames","findTypingsPackages","getMinVersion","BuildError"],"mappings":"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"}
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import type { TS } from "../../detectModules.js";
|
2
|
+
export declare function findTypingsNames({ ts }: TS, entrypoint: string, sourceDir: string, ext: string): Set<string>;
|
@@ -1,29 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
-
const ts = require("typescript");
|
4
3
|
const path = require("node:path");
|
5
4
|
const fs = require("node:fs");
|
6
|
-
function
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if (k !== "default") {
|
11
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
12
|
-
Object.defineProperty(n, k, d.get ? d : {
|
13
|
-
enumerable: true,
|
14
|
-
get: () => e[k]
|
15
|
-
});
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
n.default = e;
|
20
|
-
return Object.freeze(n);
|
21
|
-
}
|
22
|
-
const ts__namespace = /* @__PURE__ */ _interopNamespaceDefault(ts);
|
23
|
-
function createCompilerHostWithVirtualSource(sourceDir) {
|
24
|
-
return ts__namespace.createCompilerHost({
|
25
|
-
target: ts__namespace.ScriptTarget.ESNext,
|
26
|
-
moduleResolution: ts__namespace.ModuleResolutionKind.NodeNext,
|
5
|
+
function createCompilerHostWithVirtualSource(ts, sourceDir) {
|
6
|
+
return ts.createCompilerHost({
|
7
|
+
target: ts.ScriptTarget.ESNext,
|
8
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
27
9
|
baseUrl: ".",
|
28
10
|
sourceRoot: sourceDir,
|
29
11
|
noEmit: true,
|
@@ -44,9 +26,9 @@ function collectAllFilesInDir(sourceDir, ext) {
|
|
44
26
|
}
|
45
27
|
return ret;
|
46
28
|
}
|
47
|
-
function findTypingsNames(entrypoint, sourceDir, ext) {
|
48
|
-
const host = createCompilerHostWithVirtualSource(sourceDir);
|
49
|
-
const program =
|
29
|
+
function findTypingsNames({ ts }, entrypoint, sourceDir, ext) {
|
30
|
+
const host = createCompilerHostWithVirtualSource(ts, sourceDir);
|
31
|
+
const program = ts.createProgram({
|
50
32
|
rootNames: collectAllFilesInDir(sourceDir, ext),
|
51
33
|
options: {},
|
52
34
|
host
|
@@ -64,16 +46,16 @@ function findTypingsNames(entrypoint, sourceDir, ext) {
|
|
64
46
|
}
|
65
47
|
while (filesQueue.length > 0) {
|
66
48
|
let visit = function(node) {
|
67
|
-
if (
|
49
|
+
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
68
50
|
processModuleSpecifier(node.moduleSpecifier);
|
69
51
|
}
|
70
|
-
if (
|
52
|
+
if (ts.isImportTypeNode(node) && ts.isLiteralTypeNode(node.argument) && ts.isStringLiteral(node.argument.literal)) {
|
71
53
|
processModuleSpecifier(node.argument.literal);
|
72
54
|
}
|
73
|
-
if (
|
55
|
+
if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
|
74
56
|
processModuleSpecifier(node.moduleSpecifier);
|
75
57
|
}
|
76
|
-
|
58
|
+
ts.forEachChild(node, visit);
|
77
59
|
};
|
78
60
|
const relativeCurrentFile = filesQueue.pop();
|
79
61
|
const currentFile = path.join(sourceDir, relativeCurrentFile);
|
@@ -81,7 +63,7 @@ function findTypingsNames(entrypoint, sourceDir, ext) {
|
|
81
63
|
const sourceFile = program.getSourceFile(currentFile);
|
82
64
|
if (!sourceFile) continue;
|
83
65
|
processedFiles.add(currentFile);
|
84
|
-
|
66
|
+
ts.forEachChild(sourceFile, visit);
|
85
67
|
}
|
86
68
|
return packages;
|
87
69
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findTypingsNames.js","sources":["../../../../../../src/tasks/buildTypesTask/findTypingsNames.ts"],"sourcesContent":["import * as ts from \"typescript\";\nimport { join, relative } from \"node:path\";\nimport { readdirSync, statSync } from \"node:fs\";\n\nfunction createCompilerHostWithVirtualSource(sourceDir: string) {\n return ts.createCompilerHost({\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n baseUrl: \".\",\n sourceRoot: sourceDir,\n noEmit: true,\n emitDeclarationOnly: true,\n noEmitOnError: true,\n });\n}\n\n/*\nChatGPT told me we need to specify all files in rootNames for the program to work correctly.\n */\nfunction collectAllFilesInDir(sourceDir: string, ext: string) {\n const files = readdirSync(sourceDir);\n const ret = new Array<string>();\n for (const file of files) {\n // check if the file is a directory\n const stat = statSync(join(sourceDir, file));\n if (stat.isDirectory()) {\n ret.push(...collectAllFilesInDir(join(sourceDir, file), ext));\n } else if (file.endsWith(ext)) {\n ret.push(join(sourceDir, file));\n }\n }\n\n return ret;\n}\n\nexport function findTypingsNames(\n entrypoint: string,\n sourceDir: string,\n ext: string,\n) {\n const host = createCompilerHostWithVirtualSource(sourceDir);\n const program = ts.createProgram({\n rootNames: collectAllFilesInDir(sourceDir, ext),\n options: {},\n host,\n });\n\n const packages = new Set<string>();\n const processedFiles = new Set<string>();\n const filesQueue = [relative(sourceDir, entrypoint)];\n\n function processModuleSpecifier(moduleSpecifier: ts.StringLiteral) {\n const moduleName = moduleSpecifier.text;\n if (moduleName.startsWith(\".\")) {\n filesQueue.push(moduleName.replace(/\\.js$/, ext));\n return;\n }\n\n packages.add(moduleName);\n }\n\n while (filesQueue.length > 0) {\n const relativeCurrentFile = filesQueue.pop()!;\n const currentFile = join(sourceDir, relativeCurrentFile);\n if (processedFiles.has(currentFile)) continue;\n\n const sourceFile = program.getSourceFile(currentFile);\n if (!sourceFile) continue;\n\n function visit(node: ts.Node) {\n // import \"moduleSpecifier\";\n if (\n ts.isImportDeclaration(node) &&\n ts.isStringLiteral(node.moduleSpecifier)\n ) {\n processModuleSpecifier(node.moduleSpecifier);\n }\n\n // Generic<import(\"node\")>;\n if (\n ts.isImportTypeNode(node) &&\n ts.isLiteralTypeNode(node.argument) &&\n ts.isStringLiteral(node.argument.literal)\n ) {\n processModuleSpecifier(node.argument.literal);\n }\n\n // export * from \"moduleSpecifier\";\n if (\n ts.isExportDeclaration(node) &&\n node.moduleSpecifier &&\n ts.isStringLiteral(node.moduleSpecifier)\n ) {\n processModuleSpecifier(node.moduleSpecifier);\n }\n\n ts.forEachChild(node, visit);\n }\n\n processedFiles.add(currentFile);\n\n ts.forEachChild(sourceFile, visit);\n }\n\n return packages;\n}\n"],"names":["
|
1
|
+
{"version":3,"file":"findTypingsNames.js","sources":["../../../../../../src/tasks/buildTypesTask/findTypingsNames.ts"],"sourcesContent":["import type * as ts from \"typescript\";\nimport { join, relative } from \"node:path\";\nimport { readdirSync, statSync } from \"node:fs\";\nimport type { TS } from \"../../detectModules.js\";\n\nfunction createCompilerHostWithVirtualSource(ts: TS[\"ts\"], sourceDir: string) {\n return ts.createCompilerHost({\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n baseUrl: \".\",\n sourceRoot: sourceDir,\n noEmit: true,\n emitDeclarationOnly: true,\n noEmitOnError: true,\n });\n}\n\n/*\nChatGPT told me we need to specify all files in rootNames for the program to work correctly.\n */\nfunction collectAllFilesInDir(sourceDir: string, ext: string) {\n const files = readdirSync(sourceDir);\n const ret = new Array<string>();\n for (const file of files) {\n // check if the file is a directory\n const stat = statSync(join(sourceDir, file));\n if (stat.isDirectory()) {\n ret.push(...collectAllFilesInDir(join(sourceDir, file), ext));\n } else if (file.endsWith(ext)) {\n ret.push(join(sourceDir, file));\n }\n }\n\n return ret;\n}\n\nexport function findTypingsNames(\n { ts }: TS,\n entrypoint: string,\n sourceDir: string,\n ext: string,\n) {\n const host = createCompilerHostWithVirtualSource(ts, sourceDir);\n const program = ts.createProgram({\n rootNames: collectAllFilesInDir(sourceDir, ext),\n options: {},\n host,\n });\n\n const packages = new Set<string>();\n const processedFiles = new Set<string>();\n const filesQueue = [relative(sourceDir, entrypoint)];\n\n function processModuleSpecifier(moduleSpecifier: ts.StringLiteral) {\n const moduleName = moduleSpecifier.text;\n if (moduleName.startsWith(\".\")) {\n filesQueue.push(moduleName.replace(/\\.js$/, ext));\n return;\n }\n\n packages.add(moduleName);\n }\n\n while (filesQueue.length > 0) {\n const relativeCurrentFile = filesQueue.pop()!;\n const currentFile = join(sourceDir, relativeCurrentFile);\n if (processedFiles.has(currentFile)) continue;\n\n const sourceFile = program.getSourceFile(currentFile);\n if (!sourceFile) continue;\n\n function visit(node: ts.Node) {\n // import \"moduleSpecifier\";\n if (\n ts.isImportDeclaration(node) &&\n ts.isStringLiteral(node.moduleSpecifier)\n ) {\n processModuleSpecifier(node.moduleSpecifier);\n }\n\n // Generic<import(\"node\")>;\n if (\n ts.isImportTypeNode(node) &&\n ts.isLiteralTypeNode(node.argument) &&\n ts.isStringLiteral(node.argument.literal)\n ) {\n processModuleSpecifier(node.argument.literal);\n }\n\n // export * from \"moduleSpecifier\";\n if (\n ts.isExportDeclaration(node) &&\n node.moduleSpecifier &&\n ts.isStringLiteral(node.moduleSpecifier)\n ) {\n processModuleSpecifier(node.moduleSpecifier);\n }\n\n ts.forEachChild(node, visit);\n }\n\n processedFiles.add(currentFile);\n\n ts.forEachChild(sourceFile, visit);\n }\n\n return packages;\n}\n"],"names":["readdirSync","statSync","join","relative"],"mappings":";;;;AAKA,SAAS,oCAAoC,IAAc,WAAmB;AAC5E,SAAO,GAAG,mBAAmB;AAAA,IAC3B,QAAQ,GAAG,aAAa;AAAA,IACxB,kBAAkB,GAAG,qBAAqB;AAAA,IAC1C,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,qBAAqB;AAAA,IACrB,eAAe;AAAA,EAAA,CAChB;AACH;AAKA,SAAS,qBAAqB,WAAmB,KAAa;AACtD,QAAA,QAAQA,eAAY,SAAS;AAC7B,QAAA,MAAM,IAAI,MAAc;AAC9B,aAAW,QAAQ,OAAO;AAExB,UAAM,OAAOC,GAAA,SAASC,KAAK,KAAA,WAAW,IAAI,CAAC;AACvC,QAAA,KAAK,eAAe;AAClB,UAAA,KAAK,GAAG,qBAAqBA,KAAAA,KAAK,WAAW,IAAI,GAAG,GAAG,CAAC;AAAA,IACnD,WAAA,KAAK,SAAS,GAAG,GAAG;AAC7B,UAAI,KAAKA,KAAAA,KAAK,WAAW,IAAI,CAAC;AAAA,IAAA;AAAA,EAChC;AAGK,SAAA;AACT;AAEO,SAAS,iBACd,EAAE,GAAA,GACF,YACA,WACA,KACA;AACM,QAAA,OAAO,oCAAoC,IAAI,SAAS;AACxD,QAAA,UAAU,GAAG,cAAc;AAAA,IAC/B,WAAW,qBAAqB,WAAW,GAAG;AAAA,IAC9C,SAAS,CAAC;AAAA,IACV;AAAA,EAAA,CACD;AAEK,QAAA,+BAAe,IAAY;AAC3B,QAAA,qCAAqB,IAAY;AACvC,QAAM,aAAa,CAACC,KAAAA,SAAS,WAAW,UAAU,CAAC;AAEnD,WAAS,uBAAuB,iBAAmC;AACjE,UAAM,aAAa,gBAAgB;AAC/B,QAAA,WAAW,WAAW,GAAG,GAAG;AAC9B,iBAAW,KAAK,WAAW,QAAQ,SAAS,GAAG,CAAC;AAChD;AAAA,IAAA;AAGF,aAAS,IAAI,UAAU;AAAA,EAAA;AAGlB,SAAA,WAAW,SAAS,GAAG;AAQnB,QAAA,QAAT,SAAe,MAAe;AAG1B,UAAA,GAAG,oBAAoB,IAAI,KAC3B,GAAG,gBAAgB,KAAK,eAAe,GACvC;AACA,+BAAuB,KAAK,eAAe;AAAA,MAAA;AAI7C,UACE,GAAG,iBAAiB,IAAI,KACxB,GAAG,kBAAkB,KAAK,QAAQ,KAClC,GAAG,gBAAgB,KAAK,SAAS,OAAO,GACxC;AACuB,+BAAA,KAAK,SAAS,OAAO;AAAA,MAAA;AAK5C,UAAA,GAAG,oBAAoB,IAAI,KAC3B,KAAK,mBACL,GAAG,gBAAgB,KAAK,eAAe,GACvC;AACA,+BAAuB,KAAK,eAAe;AAAA,MAAA;AAG1C,SAAA,aAAa,MAAM,KAAK;AAAA,IAC7B;AAnCM,UAAA,sBAAsB,WAAW,IAAI;AACrC,UAAA,cAAcD,KAAAA,KAAK,WAAW,mBAAmB;AACnD,QAAA,eAAe,IAAI,WAAW,EAAG;AAE/B,UAAA,aAAa,QAAQ,cAAc,WAAW;AACpD,QAAI,CAAC,WAAY;AAgCjB,mBAAe,IAAI,WAAW;AAE3B,OAAA,aAAa,YAAY,KAAK;AAAA,EAAA;AAG5B,SAAA;AACT;;"}
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
import type { TS } from "../../detectModules.js";
|
2
|
+
export declare function findTypingsPackages({ ts }: TS, packages: Set<string>, sourceDir: string): {
|
2
3
|
missingTypings: Set<string>;
|
3
4
|
existingTypingPackages: Set<string>;
|
4
5
|
};
|
@@ -1,6 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
-
const ts = require("typescript");
|
4
3
|
const path = require("node:path");
|
5
4
|
function _interopNamespaceDefault(e) {
|
6
5
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
@@ -18,12 +17,11 @@ function _interopNamespaceDefault(e) {
|
|
18
17
|
n.default = e;
|
19
18
|
return Object.freeze(n);
|
20
19
|
}
|
21
|
-
const ts__namespace = /* @__PURE__ */ _interopNamespaceDefault(ts);
|
22
20
|
const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
|
23
|
-
function createVirtualHostFunctions(virtualFilePath, virtualSourceContent, originalHost) {
|
21
|
+
function createVirtualHostFunctions(ts, virtualFilePath, virtualSourceContent, originalHost) {
|
24
22
|
const getSourceFile = (fileName, languageVersion) => {
|
25
23
|
if (fileName === virtualFilePath) {
|
26
|
-
return
|
24
|
+
return ts.createSourceFile(
|
27
25
|
fileName,
|
28
26
|
virtualSourceContent,
|
29
27
|
languageVersion
|
@@ -49,13 +47,13 @@ function createVirtualHostFunctions(virtualFilePath, virtualSourceContent, origi
|
|
49
47
|
readFile
|
50
48
|
};
|
51
49
|
}
|
52
|
-
function createCompilerHostWithVirtualSource(packages, sourceDir) {
|
50
|
+
function createCompilerHostWithVirtualSource(ts, packages, sourceDir) {
|
53
51
|
const virtualSourceContent = [...packages].map((p) => `import "${p}";`).join("\n") + // for ignoring the `Generated an empty chunk: "."` error
|
54
52
|
"export const a = 1;\n";
|
55
53
|
const virtualFilePath = path__namespace.join(sourceDir, "virtual.ts");
|
56
|
-
const originalHost =
|
57
|
-
target:
|
58
|
-
moduleResolution:
|
54
|
+
const originalHost = ts.createCompilerHost({
|
55
|
+
target: ts.ScriptTarget.ESNext,
|
56
|
+
moduleResolution: ts.ModuleResolutionKind.NodeNext,
|
59
57
|
baseUrl: ".",
|
60
58
|
sourceRoot: sourceDir,
|
61
59
|
noEmit: true,
|
@@ -66,6 +64,7 @@ function createCompilerHostWithVirtualSource(packages, sourceDir) {
|
|
66
64
|
}
|
67
65
|
});
|
68
66
|
const virtualFunctions = createVirtualHostFunctions(
|
67
|
+
ts,
|
69
68
|
virtualFilePath,
|
70
69
|
virtualSourceContent,
|
71
70
|
originalHost
|
@@ -79,12 +78,13 @@ function createCompilerHostWithVirtualSource(packages, sourceDir) {
|
|
79
78
|
virtualFilePath
|
80
79
|
};
|
81
80
|
}
|
82
|
-
function findTypingsPackages(packages, sourceDir) {
|
81
|
+
function findTypingsPackages({ ts }, packages, sourceDir) {
|
83
82
|
const { host, virtualFilePath } = createCompilerHostWithVirtualSource(
|
83
|
+
ts,
|
84
84
|
packages,
|
85
85
|
sourceDir
|
86
86
|
);
|
87
|
-
const program =
|
87
|
+
const program = ts.createProgram({
|
88
88
|
rootNames: [virtualFilePath],
|
89
89
|
options: {},
|
90
90
|
host
|
@@ -99,10 +99,10 @@ function findTypingsPackages(packages, sourceDir) {
|
|
99
99
|
const existingTypingPackages = /* @__PURE__ */ new Set();
|
100
100
|
sourceFile.forEachChild((node) => {
|
101
101
|
var _a;
|
102
|
-
if (
|
102
|
+
if (ts.isImportDeclaration(node)) {
|
103
103
|
const moduleSpecifier = node.moduleSpecifier;
|
104
|
-
if (
|
105
|
-
const moduleResolution =
|
104
|
+
if (ts.isStringLiteral(moduleSpecifier)) {
|
105
|
+
const moduleResolution = ts.resolveModuleName(
|
106
106
|
moduleSpecifier.text,
|
107
107
|
virtualFilePath,
|
108
108
|
{},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findTypingsPackages.js","sources":["../../../../../../src/tasks/buildTypesTask/findTypingsPackages.ts"],"sourcesContent":["import * as ts from \"typescript\";\nimport * as path from \"node:path\";\n\ntype HostFunctions = {\n getSourceFile: ts.CompilerHost[\"getSourceFile\"];\n fileExists: ts.CompilerHost[\"fileExists\"];\n readFile: ts.CompilerHost[\"readFile\"];\n};\n\nfunction createVirtualHostFunctions(\n virtualFilePath: string,\n virtualSourceContent: string,\n originalHost: ts.CompilerHost,\n): HostFunctions {\n const getSourceFile: ts.CompilerHost[\"getSourceFile\"] = (\n fileName,\n languageVersion,\n ) => {\n if (fileName === virtualFilePath) {\n return ts.createSourceFile(\n fileName,\n virtualSourceContent,\n languageVersion,\n );\n }\n return originalHost.getSourceFile(fileName, languageVersion);\n };\n\n const fileExists: ts.CompilerHost[\"fileExists\"] = (fileName) => {\n if (fileName === virtualFilePath) {\n return true;\n }\n return originalHost.fileExists(fileName);\n };\n\n const readFile: ts.CompilerHost[\"readFile\"] = (fileName) => {\n if (fileName === virtualFilePath) {\n return virtualSourceContent;\n }\n return originalHost.readFile(fileName);\n };\n\n return {\n getSourceFile,\n fileExists,\n readFile,\n };\n}\n\nfunction createCompilerHostWithVirtualSource(\n packages: Set<string>,\n sourceDir: string,\n) {\n const virtualSourceContent =\n [...packages].map((p) => `import \"${p}\";`).join(\"\\n\") +\n // for ignoring the `Generated an empty chunk: \".\"` error\n \"export const a = 1;\\n\";\n const virtualFilePath = path.join(sourceDir, \"virtual.ts\");\n\n const originalHost = ts.createCompilerHost({\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n baseUrl: \".\",\n sourceRoot: sourceDir,\n noEmit: true,\n emitDeclarationOnly: true,\n noEmitOnError: true,\n paths: {\n \"*\": [\"node_modules/*\"],\n },\n });\n const virtualFunctions = createVirtualHostFunctions(\n virtualFilePath,\n virtualSourceContent,\n originalHost,\n );\n\n return {\n host: new Proxy(originalHost, {\n get(target, prop: keyof ts.CompilerHost) {\n return virtualFunctions[prop as keyof HostFunctions] || target[prop];\n },\n }),\n virtualFilePath,\n };\n}\n\nexport function findTypingsPackages(packages: Set<string
|
1
|
+
{"version":3,"file":"findTypingsPackages.js","sources":["../../../../../../src/tasks/buildTypesTask/findTypingsPackages.ts"],"sourcesContent":["import type * as ts from \"typescript\";\nimport * as path from \"node:path\";\nimport type { TS } from \"../../detectModules.js\";\n\ntype HostFunctions = {\n getSourceFile: ts.CompilerHost[\"getSourceFile\"];\n fileExists: ts.CompilerHost[\"fileExists\"];\n readFile: ts.CompilerHost[\"readFile\"];\n};\n\nfunction createVirtualHostFunctions(\n ts: TS[\"ts\"],\n virtualFilePath: string,\n virtualSourceContent: string,\n originalHost: ts.CompilerHost,\n): HostFunctions {\n const getSourceFile: ts.CompilerHost[\"getSourceFile\"] = (\n fileName,\n languageVersion,\n ) => {\n if (fileName === virtualFilePath) {\n return ts.createSourceFile(\n fileName,\n virtualSourceContent,\n languageVersion,\n );\n }\n return originalHost.getSourceFile(fileName, languageVersion);\n };\n\n const fileExists: ts.CompilerHost[\"fileExists\"] = (fileName) => {\n if (fileName === virtualFilePath) {\n return true;\n }\n return originalHost.fileExists(fileName);\n };\n\n const readFile: ts.CompilerHost[\"readFile\"] = (fileName) => {\n if (fileName === virtualFilePath) {\n return virtualSourceContent;\n }\n return originalHost.readFile(fileName);\n };\n\n return {\n getSourceFile,\n fileExists,\n readFile,\n };\n}\n\nfunction createCompilerHostWithVirtualSource(\n ts: TS[\"ts\"],\n packages: Set<string>,\n sourceDir: string,\n) {\n const virtualSourceContent =\n [...packages].map((p) => `import \"${p}\";`).join(\"\\n\") +\n // for ignoring the `Generated an empty chunk: \".\"` error\n \"export const a = 1;\\n\";\n const virtualFilePath = path.join(sourceDir, \"virtual.ts\");\n\n const originalHost = ts.createCompilerHost({\n target: ts.ScriptTarget.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n baseUrl: \".\",\n sourceRoot: sourceDir,\n noEmit: true,\n emitDeclarationOnly: true,\n noEmitOnError: true,\n paths: {\n \"*\": [\"node_modules/*\"],\n },\n });\n const virtualFunctions = createVirtualHostFunctions(\n ts,\n virtualFilePath,\n virtualSourceContent,\n originalHost,\n );\n\n return {\n host: new Proxy(originalHost, {\n get(target, prop: keyof ts.CompilerHost) {\n return virtualFunctions[prop as keyof HostFunctions] || target[prop];\n },\n }),\n virtualFilePath,\n };\n}\n\nexport function findTypingsPackages(\n { ts }: TS,\n packages: Set<string>,\n sourceDir: string,\n) {\n const { host, virtualFilePath } = createCompilerHostWithVirtualSource(\n ts,\n packages,\n sourceDir,\n );\n\n const program = ts.createProgram({\n rootNames: [virtualFilePath],\n options: {},\n host: host,\n });\n\n const sourceFile = program.getSourceFile(virtualFilePath);\n if (!sourceFile) {\n throw new Error(\n \"[getSourceFile] Impossible error inside findMissingTypings\",\n );\n }\n\n const missingTypings = new Set<string>();\n const existingTypingPackages = new Set<string>();\n sourceFile.forEachChild((node) => {\n if (ts.isImportDeclaration(node)) {\n const moduleSpecifier = node.moduleSpecifier;\n if (ts.isStringLiteral(moduleSpecifier)) {\n const moduleResolution = ts.resolveModuleName(\n moduleSpecifier.text,\n virtualFilePath,\n {},\n host,\n );\n\n if (!moduleResolution?.resolvedModule?.packageId) {\n missingTypings.add(moduleSpecifier.text);\n } else {\n existingTypingPackages.add(\n moduleResolution.resolvedModule.packageId.name,\n );\n }\n }\n }\n });\n\n return { missingTypings, existingTypingPackages };\n}\n"],"names":["path"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,SAAS,2BACP,IACA,iBACA,sBACA,cACe;AACT,QAAA,gBAAkD,CACtD,UACA,oBACG;AACH,QAAI,aAAa,iBAAiB;AAChC,aAAO,GAAG;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IAAA;AAEK,WAAA,aAAa,cAAc,UAAU,eAAe;AAAA,EAC7D;AAEM,QAAA,aAA4C,CAAC,aAAa;AAC9D,QAAI,aAAa,iBAAiB;AACzB,aAAA;AAAA,IAAA;AAEF,WAAA,aAAa,WAAW,QAAQ;AAAA,EACzC;AAEM,QAAA,WAAwC,CAAC,aAAa;AAC1D,QAAI,aAAa,iBAAiB;AACzB,aAAA;AAAA,IAAA;AAEF,WAAA,aAAa,SAAS,QAAQ;AAAA,EACvC;AAEO,SAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,oCACP,IACA,UACA,WACA;AACA,QAAM,uBACJ,CAAC,GAAG,QAAQ,EAAE,IAAI,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE,KAAK,IAAI;AAAA,EAEpD;AACF,QAAM,kBAAkBA,gBAAK,KAAK,WAAW,YAAY;AAEnD,QAAA,eAAe,GAAG,mBAAmB;AAAA,IACzC,QAAQ,GAAG,aAAa;AAAA,IACxB,kBAAkB,GAAG,qBAAqB;AAAA,IAC1C,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,qBAAqB;AAAA,IACrB,eAAe;AAAA,IACf,OAAO;AAAA,MACL,KAAK,CAAC,gBAAgB;AAAA,IAAA;AAAA,EACxB,CACD;AACD,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEO,SAAA;AAAA,IACL,MAAM,IAAI,MAAM,cAAc;AAAA,MAC5B,IAAI,QAAQ,MAA6B;AACvC,eAAO,iBAAiB,IAA2B,KAAK,OAAO,IAAI;AAAA,MAAA;AAAA,IACrE,CACD;AAAA,IACD;AAAA,EACF;AACF;AAEO,SAAS,oBACd,EAAE,MACF,UACA,WACA;AACM,QAAA,EAAE,MAAM,gBAAA,IAAoB;AAAA,IAChC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEM,QAAA,UAAU,GAAG,cAAc;AAAA,IAC/B,WAAW,CAAC,eAAe;AAAA,IAC3B,SAAS,CAAC;AAAA,IACV;AAAA,EAAA,CACD;AAEK,QAAA,aAAa,QAAQ,cAAc,eAAe;AACxD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,qCAAqB,IAAY;AACjC,QAAA,6CAA6B,IAAY;AACpC,aAAA,aAAa,CAAC,SAAS;;AAC5B,QAAA,GAAG,oBAAoB,IAAI,GAAG;AAChC,YAAM,kBAAkB,KAAK;AACzB,UAAA,GAAG,gBAAgB,eAAe,GAAG;AACvC,cAAM,mBAAmB,GAAG;AAAA,UAC1B,gBAAgB;AAAA,UAChB;AAAA,UACA,CAAC;AAAA,UACD;AAAA,QACF;AAEI,YAAA,GAAC,0DAAkB,mBAAlB,mBAAkC,YAAW;AACjC,yBAAA,IAAI,gBAAgB,IAAI;AAAA,QAAA,OAClC;AACkB,iCAAA;AAAA,YACrB,iBAAiB,eAAe,UAAU;AAAA,UAC5C;AAAA,QAAA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CACD;AAEM,SAAA,EAAE,gBAAgB,uBAAuB;AAClD;;"}
|
@@ -1,16 +1,6 @@
|
|
1
|
-
import { type UserConfig
|
1
|
+
import { type UserConfig } from "vite";
|
2
2
|
type ViteTaskParams = {
|
3
3
|
viteConfig: UserConfig;
|
4
4
|
};
|
5
|
-
type BuildSuccess = {
|
6
|
-
error: false;
|
7
|
-
output: Rollup.OutputChunk[];
|
8
|
-
};
|
9
|
-
type BuildErrorType = {
|
10
|
-
error: true;
|
11
|
-
errors: Array<string>;
|
12
|
-
};
|
13
|
-
type BuildResult = BuildSuccess | BuildErrorType;
|
14
|
-
export declare function buildVite({ viteConfig, }: ViteTaskParams): Promise<BuildResult>;
|
15
5
|
export declare function viteTask({ viteConfig }: ViteTaskParams): Promise<any>;
|
16
6
|
export {};
|
@@ -4,9 +4,8 @@ const vite = require("vite");
|
|
4
4
|
const errors = require("../errors.js");
|
5
5
|
const log = require("../log.js");
|
6
6
|
const error = require("../error.js");
|
7
|
-
|
8
|
-
|
9
|
-
}) {
|
7
|
+
const PrettyErrors = require("../PrettyErrors.js");
|
8
|
+
async function buildVite({ viteConfig }) {
|
10
9
|
try {
|
11
10
|
const outputs = await vite.build(viteConfig);
|
12
11
|
if (!Array.isArray(outputs)) {
|
@@ -22,6 +21,12 @@ async function buildVite({
|
|
22
21
|
)
|
23
22
|
};
|
24
23
|
} catch (e) {
|
24
|
+
if (e instanceof PrettyErrors.PrettyError) {
|
25
|
+
return {
|
26
|
+
error: true,
|
27
|
+
errors: [e]
|
28
|
+
};
|
29
|
+
}
|
25
30
|
if (e instanceof Error) {
|
26
31
|
return {
|
27
32
|
error: true,
|
@@ -37,11 +42,12 @@ async function buildVite({
|
|
37
42
|
async function viteTask({ viteConfig }) {
|
38
43
|
const outputs = await buildVite({ viteConfig });
|
39
44
|
if (outputs.error) {
|
40
|
-
throw outputs.errors.map(
|
45
|
+
throw outputs.errors.map(
|
46
|
+
(e) => e instanceof PrettyErrors.PrettyError ? e : new error.BuildError(e)
|
47
|
+
);
|
41
48
|
}
|
42
49
|
log.okLog("Vite");
|
43
50
|
return outputs.output;
|
44
51
|
}
|
45
|
-
exports.buildVite = buildVite;
|
46
52
|
exports.viteTask = viteTask;
|
47
53
|
//# sourceMappingURL=viteTask.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"viteTask.js","sources":["../../../../../src/tasks/viteTask.ts"],"sourcesContent":["import { build, type UserConfig, type Rollup } from \"vite\";\nimport { errors } from \"../errors.js\";\nimport { okLog } from \"../log.js\";\nimport { BuildError } from \"../error.js\";\n\ntype ViteTaskParams = {\n viteConfig: UserConfig;\n};\n\ntype BuildSuccess = {\n error: false;\n output: Rollup.OutputChunk[];\n};\ntype BuildErrorType = {\n error: true;\n errors: Array<string>;\n};\n\ntype BuildResult = BuildSuccess | BuildErrorType;\n\
|
1
|
+
{"version":3,"file":"viteTask.js","sources":["../../../../../src/tasks/viteTask.ts"],"sourcesContent":["import { build, type UserConfig, type Rollup } from \"vite\";\nimport { errors } from \"../errors.js\";\nimport { okLog } from \"../log.js\";\nimport { BuildError } from \"../error.js\";\nimport { PrettyError } from \"../PrettyErrors.js\";\n\ntype ViteTaskParams = {\n viteConfig: UserConfig;\n};\n\ntype BuildSuccess = {\n error: false;\n output: Rollup.OutputChunk[];\n};\ntype BuildErrorType = {\n error: true;\n errors: Array<string | PrettyError>;\n};\n\ntype BuildResult = BuildSuccess | BuildErrorType;\n\nasync function buildVite({ viteConfig }: ViteTaskParams): Promise<BuildResult> {\n try {\n const outputs = await build(viteConfig);\n if (!Array.isArray(outputs)) {\n return {\n error: true,\n errors: [errors.rollupError],\n };\n }\n\n return {\n error: false,\n output: outputs.flatMap((x) =>\n x.output.filter((x) => x.type === \"chunk\"),\n ),\n };\n } catch (e) {\n if (e instanceof PrettyError) {\n return {\n error: true,\n errors: [e],\n };\n }\n if (e instanceof Error) {\n return {\n error: true,\n errors: [e.message],\n };\n }\n }\n return {\n error: true,\n errors: [errors.rollupError],\n };\n}\n\nexport async function viteTask({ viteConfig }: ViteTaskParams) {\n const outputs = await buildVite({ viteConfig });\n if (outputs.error) {\n throw outputs.errors.map((e) =>\n e instanceof PrettyError ? e : new BuildError(e),\n );\n }\n\n okLog(\"Vite\");\n return outputs.output;\n}\n"],"names":["build","errors","x","PrettyError","BuildError","okLog"],"mappings":";;;;;;;AAqBA,eAAe,UAAU,EAAE,cAAoD;AACzE,MAAA;AACI,UAAA,UAAU,MAAMA,KAAA,MAAM,UAAU;AACtC,QAAI,CAAC,MAAM,QAAQ,OAAO,GAAG;AACpB,aAAA;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,CAACC,OAAAA,OAAO,WAAW;AAAA,MAC7B;AAAA,IAAA;AAGK,WAAA;AAAA,MACL,OAAO;AAAA,MACP,QAAQ,QAAQ;AAAA,QAAQ,CAAC,MACvB,EAAE,OAAO,OAAO,CAACC,OAAMA,GAAE,SAAS,OAAO;AAAA,MAAA;AAAA,IAE7C;AAAA,WACO,GAAG;AACV,QAAI,aAAaC,aAAAA,aAAa;AACrB,aAAA;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,CAAC,CAAC;AAAA,MACZ;AAAA,IAAA;AAEF,QAAI,aAAa,OAAO;AACf,aAAA;AAAA,QACL,OAAO;AAAA,QACP,QAAQ,CAAC,EAAE,OAAO;AAAA,MACpB;AAAA,IAAA;AAAA,EACF;AAEK,SAAA;AAAA,IACL,OAAO;AAAA,IACP,QAAQ,CAACF,OAAAA,OAAO,WAAW;AAAA,EAC7B;AACF;AAEsB,eAAA,SAAS,EAAE,cAA8B;AAC7D,QAAM,UAAU,MAAM,UAAU,EAAE,YAAY;AAC9C,MAAI,QAAQ,OAAO;AACjB,UAAM,QAAQ,OAAO;AAAA,MAAI,CAAC,MACxB,aAAaE,aAAAA,cAAc,IAAI,IAAIC,iBAAW,CAAC;AAAA,IACjD;AAAA,EAAA;AAGFC,MAAAA,MAAM,MAAM;AACZ,SAAO,QAAQ;AACjB;;"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PrettyErrors.mjs","sources":["../../../../src/PrettyErrors.ts"],"sourcesContent":["export class PrettyError extends Error {}\n"],"names":[],"mappings":"AAAO,MAAM,oBAAoB,MAAM;AAAC;"}
|
@@ -5,8 +5,9 @@ type CreateViteConfigParam = {
|
|
5
5
|
dirs: Dirs;
|
6
6
|
packageJson: PackageJson;
|
7
7
|
modules: DetectedModules;
|
8
|
+
test?: boolean;
|
8
9
|
};
|
9
|
-
export declare function createViteConfig({ dirs, packageJson, modules, }: CreateViteConfigParam): {
|
10
|
+
export declare function createViteConfig({ dirs, packageJson, modules, test, }: CreateViteConfigParam): {
|
10
11
|
viteConfig: import("vite").UserConfig;
|
11
12
|
entrypoints: Map<string, string>;
|
12
13
|
bins: Map<string, string>;
|
@@ -6,6 +6,7 @@ import { defineConfig } from "vite";
|
|
6
6
|
import { babelPlugin } from "./plugins/babel/index.mjs";
|
7
7
|
import { reactPlugin } from "./plugins/react/index.mjs";
|
8
8
|
import "semver";
|
9
|
+
import { importsPlugin } from "./plugins/imports/index.mjs";
|
9
10
|
function mapToObject(map) {
|
10
11
|
const obj = {};
|
11
12
|
for (const [key, value] of map) {
|
@@ -13,38 +14,11 @@ function mapToObject(map) {
|
|
13
14
|
}
|
14
15
|
return obj;
|
15
16
|
}
|
16
|
-
function createExternalDepValidator(packageJson) {
|
17
|
-
const allExternalPackages = /* @__PURE__ */ new Set();
|
18
|
-
for (const key of [
|
19
|
-
"dependencies",
|
20
|
-
"optionalDependencies",
|
21
|
-
"peerDependencies"
|
22
|
-
]) {
|
23
|
-
for (const dep of Object.keys(packageJson[key] ?? {})) {
|
24
|
-
allExternalPackages.add(dep);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
allExternalPackages.add(packageJson.name);
|
28
|
-
return (id) => {
|
29
|
-
if (id.startsWith("node:")) {
|
30
|
-
return true;
|
31
|
-
}
|
32
|
-
const segments = id.split("/");
|
33
|
-
let current = "";
|
34
|
-
for (const segment of segments) {
|
35
|
-
current += segment;
|
36
|
-
if (allExternalPackages.has(current)) {
|
37
|
-
return true;
|
38
|
-
}
|
39
|
-
current += "/";
|
40
|
-
}
|
41
|
-
return false;
|
42
|
-
};
|
43
|
-
}
|
44
17
|
function createViteConfig({
|
45
18
|
dirs,
|
46
19
|
packageJson,
|
47
|
-
modules
|
20
|
+
modules,
|
21
|
+
test
|
48
22
|
}) {
|
49
23
|
const { sourceDir, outDir, esmOutDir, cjsOutDir } = dirs;
|
50
24
|
const entrypoints = /* @__PURE__ */ new Map();
|
@@ -61,11 +35,11 @@ function createViteConfig({
|
|
61
35
|
}
|
62
36
|
}
|
63
37
|
const mergedEntries = new Map([...entrypoints, ...bins]);
|
64
|
-
const depsValidator = createExternalDepValidator(packageJson);
|
65
38
|
const esmRelativeOutPath = relative(outDir, esmOutDir);
|
66
39
|
const cjsRelativeOutPath = relative(outDir, cjsOutDir);
|
67
40
|
const viteConfig = defineConfig({
|
68
41
|
plugins: [
|
42
|
+
importsPlugin(packageJson, test),
|
69
43
|
reactPlugin({ modules }),
|
70
44
|
babelPlugin({ packageJson, dirs, modules })
|
71
45
|
],
|
@@ -110,7 +84,6 @@ function createViteConfig({
|
|
110
84
|
}
|
111
85
|
},
|
112
86
|
rollupOptions: {
|
113
|
-
external: depsValidator,
|
114
87
|
output: {
|
115
88
|
preserveModulesRoot: sourceDir,
|
116
89
|
exports: "named",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createViteConfig.mjs","sources":["../../../../src/createViteConfig.ts"],"sourcesContent":["import { type Dirs } from \"./resolveDirs.js\";\nimport { type PackageJson } from \"./packageJson.js\";\nimport { join, relative } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport { babelPlugin } from \"./plugins/babel/index.js\";\nimport { reactPlugin } from \"./plugins/react/index.js\";\nimport { type DetectedModules } from \"./detectModules.js\";\n\ntype CreateViteConfigParam = {\n dirs: Dirs;\n packageJson: PackageJson;\n modules: DetectedModules;\n};\n\nfunction mapToObject(map: Map<string, string>) {\n const obj: Record<string, string> = {};\n for (const [key, value] of map) {\n obj[key] = value;\n }\n return obj;\n}\n\
|
1
|
+
{"version":3,"file":"createViteConfig.mjs","sources":["../../../../src/createViteConfig.ts"],"sourcesContent":["import { type Dirs } from \"./resolveDirs.js\";\nimport { type PackageJson } from \"./packageJson.js\";\nimport { join, relative } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport { babelPlugin } from \"./plugins/babel/index.js\";\nimport { reactPlugin } from \"./plugins/react/index.js\";\nimport { type DetectedModules } from \"./detectModules.js\";\nimport { importsPlugin } from \"./plugins/imports/index.js\";\n\ntype CreateViteConfigParam = {\n dirs: Dirs;\n packageJson: PackageJson;\n modules: DetectedModules;\n test?: boolean;\n};\n\nfunction mapToObject(map: Map<string, string>) {\n const obj: Record<string, string> = {};\n for (const [key, value] of map) {\n obj[key] = value;\n }\n return obj;\n}\n\nexport function createViteConfig({\n dirs,\n packageJson,\n modules,\n test,\n}: CreateViteConfigParam) {\n const { sourceDir, outDir, esmOutDir, cjsOutDir } = dirs;\n\n const entrypoints = new Map<string, string>();\n if (packageJson.exports) {\n for (const [key, value] of packageJson.exports) {\n const entry = join(sourceDir, value);\n entrypoints.set(key, entry);\n }\n }\n\n const bins = new Map<string, string>();\n if (packageJson.bin) {\n for (const [key, value] of packageJson.bin) {\n bins.set(key, join(sourceDir, value));\n }\n }\n\n const mergedEntries = new Map([...entrypoints, ...bins]);\n\n const esmRelativeOutPath = relative(outDir, esmOutDir);\n const cjsRelativeOutPath = relative(outDir, cjsOutDir);\n const viteConfig = defineConfig({\n plugins: [\n importsPlugin(packageJson, test),\n reactPlugin({ modules }),\n babelPlugin({ packageJson, dirs, modules }),\n ],\n publicDir: false,\n root: sourceDir,\n logLevel: \"silent\",\n build: {\n outDir,\n write: true,\n minify: false,\n emptyOutDir: false,\n sourcemap: true,\n assetsInlineLimit: 0,\n terserOptions: {\n compress: false,\n mangle: false,\n },\n lib: {\n entry: mapToObject(mergedEntries),\n formats: [\"es\", \"cjs\"],\n fileName: (format, entryName) => {\n const entrypoint = mergedEntries.get(entryName);\n if (!entrypoint) {\n const noExt = entryName.replace(/\\.[^.]+$/, \"\");\n if (format === \"es\") {\n return join(esmRelativeOutPath, `${noExt}.mjs`);\n } else {\n return join(cjsRelativeOutPath, `${noExt}.js`);\n }\n }\n\n if (format === \"es\") {\n return join(\n esmRelativeOutPath,\n relative(sourceDir, entrypoint).replace(/\\.[^.]+$/, \"\") + \".mjs\",\n );\n } else {\n return join(\n cjsRelativeOutPath,\n relative(sourceDir, entrypoint).replace(/\\.[^.]+$/, \"\") + \".js\",\n );\n }\n },\n },\n rollupOptions: {\n output: {\n preserveModulesRoot: sourceDir,\n exports: \"named\",\n preserveModules: true,\n },\n },\n },\n });\n\n return { viteConfig, entrypoints, bins };\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,SAAS,YAAY,KAA0B;AAC7C,QAAM,MAA8B,CAAC;AACrC,aAAW,CAAC,KAAK,KAAK,KAAK,KAAK;AAC9B,QAAI,GAAG,IAAI;AAAA,EAAA;AAEN,SAAA;AACT;AAEO,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA0B;AACxB,QAAM,EAAE,WAAW,QAAQ,WAAW,UAAc,IAAA;AAE9C,QAAA,kCAAkB,IAAoB;AAC5C,MAAI,YAAY,SAAS;AACvB,eAAW,CAAC,KAAK,KAAK,KAAK,YAAY,SAAS;AACxC,YAAA,QAAQ,KAAK,WAAW,KAAK;AACvB,kBAAA,IAAI,KAAK,KAAK;AAAA,IAAA;AAAA,EAC5B;AAGI,QAAA,2BAAW,IAAoB;AACrC,MAAI,YAAY,KAAK;AACnB,eAAW,CAAC,KAAK,KAAK,KAAK,YAAY,KAAK;AAC1C,WAAK,IAAI,KAAK,KAAK,WAAW,KAAK,CAAC;AAAA,IAAA;AAAA,EACtC;AAGI,QAAA,gBAAgB,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;AAEjD,QAAA,qBAAqB,SAAS,QAAQ,SAAS;AAC/C,QAAA,qBAAqB,SAAS,QAAQ,SAAS;AACrD,QAAM,aAAa,aAAa;AAAA,IAC9B,SAAS;AAAA,MACP,cAAc,aAAa,IAAI;AAAA,MAC/B,YAAY,EAAE,SAAS;AAAA,MACvB,YAAY,EAAE,aAAa,MAAM,QAAS,CAAA;AAAA,IAC5C;AAAA,IACA,WAAW;AAAA,IACX,MAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO;AAAA,MACL;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAW;AAAA,MACX,mBAAmB;AAAA,MACnB,eAAe;AAAA,QACb,UAAU;AAAA,QACV,QAAQ;AAAA,MACV;AAAA,MACA,KAAK;AAAA,QACH,OAAO,YAAY,aAAa;AAAA,QAChC,SAAS,CAAC,MAAM,KAAK;AAAA,QACrB,UAAU,CAAC,QAAQ,cAAc;AACzB,gBAAA,aAAa,cAAc,IAAI,SAAS;AAC9C,cAAI,CAAC,YAAY;AACf,kBAAM,QAAQ,UAAU,QAAQ,YAAY,EAAE;AAC9C,gBAAI,WAAW,MAAM;AACnB,qBAAO,KAAK,oBAAoB,GAAG,KAAK,MAAM;AAAA,YAAA,OACzC;AACL,qBAAO,KAAK,oBAAoB,GAAG,KAAK,KAAK;AAAA,YAAA;AAAA,UAC/C;AAGF,cAAI,WAAW,MAAM;AACZ,mBAAA;AAAA,cACL;AAAA,cACA,SAAS,WAAW,UAAU,EAAE,QAAQ,YAAY,EAAE,IAAI;AAAA,YAC5D;AAAA,UAAA,OACK;AACE,mBAAA;AAAA,cACL;AAAA,cACA,SAAS,WAAW,UAAU,EAAE,QAAQ,YAAY,EAAE,IAAI;AAAA,YAC5D;AAAA,UAAA;AAAA,QACF;AAAA,MAEJ;AAAA,MACA,eAAe;AAAA,QACb,QAAQ;AAAA,UACN,qBAAqB;AAAA,UACrB,SAAS;AAAA,UACT,iBAAiB;AAAA,QAAA;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CACD;AAEM,SAAA,EAAE,YAAY,aAAa,KAAK;AACzC;"}
|
@@ -1,11 +1,23 @@
|
|
1
1
|
import { type PackageJson } from "./packageJson.js";
|
2
2
|
import semver from "semver";
|
3
|
+
import type { Dirs } from "./resolveDirs.js";
|
4
|
+
export type TS = {
|
5
|
+
ts: typeof import("typescript");
|
6
|
+
parsedConfig: import("typescript").ParsedCommandLine;
|
7
|
+
host: import("typescript").CompilerHost;
|
8
|
+
};
|
3
9
|
export type DetectedModules = {
|
4
|
-
ts?:
|
10
|
+
ts?: TS;
|
5
11
|
babel?: typeof import("@babel/core");
|
6
12
|
react?: "legacy" | "modern";
|
7
13
|
};
|
8
14
|
type DepType = "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies";
|
9
15
|
export declare function getMinVersion(packageJson: PackageJson, depName: string, exclude: DepType[]): semver.SemVer | null;
|
10
|
-
export declare function detectModules(packageJson: PackageJson): Promise<
|
16
|
+
export declare function detectModules(packageJson: PackageJson, dirs: Dirs): Promise<{
|
17
|
+
error: false;
|
18
|
+
modules: DetectedModules;
|
19
|
+
} | {
|
20
|
+
error: true;
|
21
|
+
errors: Array<string>;
|
22
|
+
}>;
|
11
23
|
export {};
|