smartbundle 0.14.1 → 0.15.0-alpha.1
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/README.md +6 -1
- package/__bin__/smartbundle-monorepo-link.js +2 -0
- package/__compiled__/cjs/src/args.d.ts +9 -1
- package/__compiled__/cjs/src/args.js +3 -0
- package/__compiled__/cjs/src/args.js.map +1 -1
- package/__compiled__/cjs/src/detectModules.d.ts +25 -11
- package/__compiled__/cjs/src/detectModules.js +165 -28
- package/__compiled__/cjs/src/detectModules.js.map +1 -1
- package/__compiled__/cjs/src/index.d.ts +1 -1
- package/__compiled__/cjs/src/index.js +11 -5
- package/__compiled__/cjs/src/index.js.map +1 -1
- package/__compiled__/cjs/src/monorepo/buildAll.js +62 -0
- package/__compiled__/cjs/src/monorepo/buildAll.js.map +1 -0
- package/__compiled__/cjs/src/monorepo/convertPackageJson.d.ts +31 -0
- package/__compiled__/cjs/src/monorepo/convertPackageJson.js +40 -0
- package/__compiled__/cjs/src/monorepo/convertPackageJson.js.map +1 -0
- package/__compiled__/cjs/src/monorepo/createLinkPackages/createLinkPackages.js +92 -0
- package/__compiled__/cjs/src/monorepo/createLinkPackages/createLinkPackages.js.map +1 -0
- package/__compiled__/cjs/src/monorepo/link.js +11 -0
- package/__compiled__/cjs/src/monorepo/link.js.map +1 -0
- package/__compiled__/cjs/src/monorepo/parseMonorepo/parseMonorepo.js +106 -0
- package/__compiled__/cjs/src/monorepo/parseMonorepo/parseMonorepo.js.map +1 -0
- package/__compiled__/cjs/src/packageJson.d.ts +5 -0
- package/__compiled__/cjs/src/packageJson.js +2 -0
- package/__compiled__/cjs/src/packageJson.js.map +1 -1
- package/__compiled__/cjs/src/plugins/babel/index.js +1 -1
- package/__compiled__/cjs/src/plugins/babel/index.js.map +1 -1
- package/__compiled__/cjs/src/plugins/react/index.js +3 -2
- package/__compiled__/cjs/src/plugins/react/index.js.map +1 -1
- package/__compiled__/cjs/src/run.js +47 -8
- package/__compiled__/cjs/src/run.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/buildTypesTask.js +1 -3
- package/__compiled__/cjs/src/tasks/buildTypesTask/buildTypesTask.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.d.ts +2 -2
- package/__compiled__/cjs/src/tasks/buildTypesTask/callTypescript.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsNames.d.ts +2 -2
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsNames.js.map +1 -1
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsPackages.d.ts +2 -2
- package/__compiled__/cjs/src/tasks/buildTypesTask/findTypingsPackages.js.map +1 -1
- package/__compiled__/cjs/src/tasks/gitignoreTask.d.ts +6 -0
- package/__compiled__/cjs/src/tasks/gitignoreTask.js +14 -0
- package/__compiled__/cjs/src/tasks/gitignoreTask.js.map +1 -0
- package/__compiled__/cjs/src/writePackageJson.js +2 -0
- package/__compiled__/cjs/src/writePackageJson.js.map +1 -1
- package/__compiled__/esm/src/args.d.mts +9 -1
- package/__compiled__/esm/src/args.mjs +3 -0
- package/__compiled__/esm/src/args.mjs.map +1 -1
- package/__compiled__/esm/src/detectModules.d.mts +25 -11
- package/__compiled__/esm/src/detectModules.mjs +165 -28
- package/__compiled__/esm/src/detectModules.mjs.map +1 -1
- package/__compiled__/esm/src/index.d.mts +1 -1
- package/__compiled__/esm/src/index.mjs +11 -5
- package/__compiled__/esm/src/index.mjs.map +1 -1
- package/__compiled__/esm/src/monorepo/buildAll.mjs +62 -0
- package/__compiled__/esm/src/monorepo/buildAll.mjs.map +1 -0
- package/__compiled__/esm/src/monorepo/convertPackageJson.d.mts +31 -0
- package/__compiled__/esm/src/monorepo/convertPackageJson.mjs +40 -0
- package/__compiled__/esm/src/monorepo/convertPackageJson.mjs.map +1 -0
- package/__compiled__/esm/src/monorepo/createLinkPackages/createLinkPackages.mjs +92 -0
- package/__compiled__/esm/src/monorepo/createLinkPackages/createLinkPackages.mjs.map +1 -0
- package/__compiled__/esm/src/monorepo/link.mjs +10 -0
- package/__compiled__/esm/src/monorepo/link.mjs.map +1 -0
- package/__compiled__/esm/src/monorepo/parseMonorepo/parseMonorepo.mjs +106 -0
- package/__compiled__/esm/src/monorepo/parseMonorepo/parseMonorepo.mjs.map +1 -0
- package/__compiled__/esm/src/packageJson.d.mts +5 -0
- package/__compiled__/esm/src/packageJson.mjs +2 -0
- package/__compiled__/esm/src/packageJson.mjs.map +1 -1
- package/__compiled__/esm/src/plugins/babel/index.mjs +1 -1
- package/__compiled__/esm/src/plugins/babel/index.mjs.map +1 -1
- package/__compiled__/esm/src/plugins/react/index.mjs +3 -2
- package/__compiled__/esm/src/plugins/react/index.mjs.map +1 -1
- package/__compiled__/esm/src/run.mjs +47 -8
- package/__compiled__/esm/src/run.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/buildTypesTask.mjs +1 -3
- package/__compiled__/esm/src/tasks/buildTypesTask/buildTypesTask.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.d.mts +2 -2
- package/__compiled__/esm/src/tasks/buildTypesTask/callTypescript.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsNames.d.mts +2 -2
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsNames.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsPackages.d.mts +2 -2
- package/__compiled__/esm/src/tasks/buildTypesTask/findTypingsPackages.mjs.map +1 -1
- package/__compiled__/esm/src/tasks/gitignoreTask.d.mts +6 -0
- package/__compiled__/esm/src/tasks/gitignoreTask.mjs +14 -0
- package/__compiled__/esm/src/tasks/gitignoreTask.mjs.map +1 -0
- package/__compiled__/esm/src/writePackageJson.mjs +2 -0
- package/__compiled__/esm/src/writePackageJson.mjs.map +1 -1
- package/package.json +19 -13
@@ -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, type
|
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 TSModule } 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: TSModule;\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 // we create maps for ts and tsx because it can have any of these extensions\n // I don't want to detect the original ext,\n // so I've decided just create two maps and calculate the original file name outside of this function\n const sourceFileNameTS = fileName.replace(/\\.d\\.ts$/, \".ts\"); // Assuming source files have .ts extension\n const sourceFileNameTSX = fileName.replace(/\\.d\\.ts$/, \".tsx\"); // 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(sourceFileNameTS, esmFinalPath);\n sourceToEsmDtsMap.set(sourceFileNameTSX, 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(sourceFileNameTS, cjsFinalPath);\n sourceToCjsDtsMap.set(sourceFileNameTSX, 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,eAAe,QAAgB,UAAkB;AACxD,SAAO,CAAC,MAAc;AACpB,UAAM,MAAMA,gBAAK,KAAK,QAAQA,gBAAK,QAAQ,QAAQ,CAAC;AACpD,WAAOC,cAAG,WAAWD,gBAAK,KAAK,KAAK,CAAC,CAAC;AAAA,EACxC;AACF;AAEA,eAAsB,eAAe;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,QAAM,EAAE,WAAW,QAAQ,WAAW,UAAc,IAAA;AAG9C,QAAA,wCAAwB,IAAoB;AAC5C,QAAA,wCAAwB,IAAoB;AAC5C,QAAA,UAAU,GAAG,GAAG;AAAA,IACpB;AAAA,IACA,GAAG,aAAa;AAAA,IAChB,GAAG;AAAA,EACL;AACA,UAAQ,KAAK,QAAW,CAAC,UAAU,SAAS;AAG1C,UAAM,eAAeA,gBAAK,SAAS,WAAW,QAAQ;AAItD,UAAM,mBAAmB,SAAS,QA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B;AAC5D,QAAI,eAAe;AACjB,YAAM,gBAAgBG,iBAAA;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,iBAAW,KAAK,eAAe;AAC7B,iBAAS,IAAI,CAAC;AAAA,MAAA;AAAA,IAChB;AAGI,UAAA,gBAAgB,kBAAkB,IAAI,gBAAgB;AAC5D,QAAI,eAAe;AACjB,YAAM,gBAAgBA,iBAAA;AAAA,QACpB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,iBAAW,KAAK,eAAe;AAC7B,iBAAS,IAAI,CAAC;AAAA,MAAA;AAAA,IAChB;AAAA,EACF;AAKI,QAAA,EAAE,gBAAgB,uBAAA,IAA2BC,oBAAA;AAAA,IACjD;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,aAAW,OAAO,wBAAwB;AAEtC,QAAAC,cAAA,cAAc,aAAa,KAAK;AAAA,MAC9B;AAAA,MACA;AAAA,IACD,CAAA,KAAK,MACN;AACA,qBAAe,IAAI,GAAG;AAAA,IAAA;AAAA,EACxB;AAEE,MAAA,eAAe,OAAO,GAAG;AAC3B,UAAM,WAAW,CAAC,GAAG,cAAc,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,KAAK,IAAI;AACnE,UAAM,IAAIC,MAAA;AAAA,MACR,mDAAmD,QAAQ;AAAA,IAC7D;AAAA,EAAA;AAIK,SAAA;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;;"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import type {
|
2
|
-
export declare function findTypingsNames({ ts }:
|
1
|
+
import type { TSModule } from "../../detectModules.js";
|
2
|
+
export declare function findTypingsNames({ ts }: TSModule, entrypoint: string, sourceDir: string, ext: string): Set<string>;
|
@@ -1 +1 @@
|
|
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 {
|
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 { TSModule } from \"../../detectModules.js\";\n\nfunction createCompilerHostWithVirtualSource(ts: TSModule[\"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 }: TSModule,\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,IAAoB,WAAmB;AAClF,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;AA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;AAE3B,OAAA,aAAa,YAAY,KAAK;AAAA,EAAA;AAG5B,SAAA;AACT;;"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import type {
|
2
|
-
export declare function findTypingsPackages({ ts }:
|
1
|
+
import type { TSModule } from "../../detectModules.js";
|
2
|
+
export declare function findTypingsPackages({ ts }: TSModule, packages: Set<string>, sourceDir: string): {
|
3
3
|
missingTypings: Set<string>;
|
4
4
|
existingTypingPackages: Set<string>;
|
5
5
|
};
|
@@ -1 +1 @@
|
|
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 {
|
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 { TSModule } 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: TSModule[\"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: TSModule[\"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 }: TSModule,\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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,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;;"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
3
|
+
const fs = require("node:fs/promises");
|
4
|
+
const path = require("node:path");
|
5
|
+
async function gitignoreTask({ dirs }) {
|
6
|
+
const { outDir } = dirs;
|
7
|
+
const gitignoreContent = "*\n";
|
8
|
+
const gitignorePath = path.join(outDir, ".gitignore");
|
9
|
+
await fs.writeFile(gitignorePath, gitignoreContent);
|
10
|
+
const npmignorePath = path.join(outDir, ".npmignore");
|
11
|
+
await fs.writeFile(npmignorePath, "");
|
12
|
+
}
|
13
|
+
exports.gitignoreTask = gitignoreTask;
|
14
|
+
//# sourceMappingURL=gitignoreTask.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"gitignoreTask.js","sources":["../../../../../src/tasks/gitignoreTask.ts"],"sourcesContent":["import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { Dirs } from \"../resolveDirs.js\";\n\ntype GitignoreTaskArg = {\n dirs: Dirs;\n};\n\nexport async function gitignoreTask({ dirs }: GitignoreTaskArg) {\n const { outDir } = dirs;\n\n // Ignore the all files to prevent commiting the dist\n const gitignoreContent = \"*\\n\";\n\n const gitignorePath = path.join(outDir, \".gitignore\");\n await fs.writeFile(gitignorePath, gitignoreContent);\n\n // We need to have empty .npmignore to avoid reading .gitignore in pnpm publishing\n const npmignorePath = path.join(outDir, \".npmignore\");\n await fs.writeFile(npmignorePath, \"\");\n}\n"],"names":[],"mappings":";;;;AAQsB,eAAA,cAAc,EAAE,QAA0B;AACxD,QAAA,EAAE,WAAW;AAGnB,QAAM,mBAAmB;AAEzB,QAAM,gBAAgB,KAAK,KAAK,QAAQ,YAAY;AAC9C,QAAA,GAAG,UAAU,eAAe,gBAAgB;AAGlD,QAAM,gBAAgB,KAAK,KAAK,QAAQ,YAAY;AAC9C,QAAA,GAAG,UAAU,eAAe,EAAE;AACtC;;"}
|
@@ -4,6 +4,7 @@ const fs = require("node:fs/promises");
|
|
4
4
|
require("zod");
|
5
5
|
require("node:path");
|
6
6
|
const log = require("./log.js");
|
7
|
+
const convertPackageJson = require("./monorepo/convertPackageJson.js");
|
7
8
|
function extractValue(value) {
|
8
9
|
if (!value) {
|
9
10
|
return void 0;
|
@@ -38,6 +39,7 @@ async function writePackageJson(outDir, parsed, { exportsMap, binsMap }) {
|
|
38
39
|
allExports["./package.json"] = "./package.json";
|
39
40
|
const bin = binsMap.size > 0 ? Object.fromEntries(binsMap) : void 0;
|
40
41
|
const rootExport = typeof allExports["."] === "object" ? allExports["."] : void 0;
|
42
|
+
parsed = convertPackageJson.convertPackageJson(parsed);
|
41
43
|
const res = {
|
42
44
|
name: parsed.name,
|
43
45
|
type: "commonjs",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"writePackageJson.js","sources":["../../../../src/writePackageJson.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { type PackageJson } from \"./packageJson.js\";\nimport { okLog } from \"./log.js\";\n\nexport type ExportsObject = {\n mjs?: string;\n dmts?: string;\n dcts?: string;\n cjs?: string;\n raw?: string;\n};\n\ntype BuildResult = {\n exportsMap: Map<string, ExportsObject>;\n binsMap: Map<string, string>;\n};\n\ntype ExportsPackageJsonObj =\n | {\n import?: ExportsPackageJsonObj;\n require?: ExportsPackageJsonObj;\n types?: string;\n default?: string;\n }\n | string;\n\nfunction extractValue(value?: ExportsPackageJsonObj) {\n if (!value) {\n return undefined;\n }\n if (typeof value === \"string\") {\n return value;\n }\n return value.default;\n}\n\nexport async function writePackageJson(\n outDir: string,\n parsed: PackageJson,\n { exportsMap, binsMap }: BuildResult,\n) {\n // we always want to have `exports` property in the target package.json\n // If you want to export something, please, specify them\n const allExports: Record<string, ExportsPackageJsonObj> = {};\n for (const [key, value] of exportsMap) {\n const anExport: ExportsPackageJsonObj = {};\n\n if (value.mjs) {\n anExport.import = {};\n if (value.dmts) {\n anExport.import.types = value.dmts;\n }\n anExport.import.default = value.mjs;\n }\n if (value.cjs) {\n anExport.require = {};\n if (value.dcts) {\n anExport.require.types = value.dcts;\n }\n anExport.require.default = value.cjs;\n }\n\n // should be first for correct resolving\n anExport.types = value.dcts ?? value.dmts;\n // because we need to have default and types key on the end\n // JSON.stringify will put it on the end if we put value at the last step\n anExport.default = value.cjs;\n\n allExports[key] = anExport;\n }\n allExports[\"./package.json\"] = \"./package.json\";\n\n const bin = binsMap.size > 0 ? Object.fromEntries(binsMap) : undefined;\n\n const rootExport =\n typeof allExports[\".\"] === \"object\" ? allExports[\".\"] : undefined;\n const res = {\n name: parsed.name,\n type: \"commonjs\",\n version: parsed.version,\n bin,\n types: rootExport?.types,\n module: extractValue(rootExport?.import),\n main: extractValue(rootExport?.require),\n description: parsed.description ?? \"\",\n exports: allExports,\n dependencies: parsed.dependencies ?? undefined,\n optionalDependencies: parsed.optionalDependencies ?? undefined,\n repository: parsed.repository,\n keywords: parsed.keywords,\n author: parsed.author,\n contributors: parsed.contributors,\n license: parsed.license,\n peerDependencies: parsed.peerDependencies,\n engines: parsed.engines,\n browser: parsed.browser,\n funding: parsed.funding,\n os: parsed.os,\n cpu: parsed.cpu,\n maintainers: parsed.maintainers,\n bugs: parsed.bugs,\n sideEffects: parsed.sideEffects,\n unpkg: parsed.unpkg,\n homepage: parsed.homepage,\n devDependencies: parsed.devDependencies,\n peerDependenciesMeta: parsed.peerDependenciesMeta,\n };\n\n await writeFile(`${outDir}/package.json`, JSON.stringify(res, null, 2));\n\n okLog(\"package.json\");\n}\n"],"names":["writeFile","okLog"],"mappings":"
|
1
|
+
{"version":3,"file":"writePackageJson.js","sources":["../../../../src/writePackageJson.ts"],"sourcesContent":["import { writeFile } from \"node:fs/promises\";\nimport { type PackageJson } from \"./packageJson.js\";\nimport { okLog } from \"./log.js\";\nimport { convertPackageJson } from \"./monorepo/convertPackageJson.js\";\n\nexport type ExportsObject = {\n mjs?: string;\n dmts?: string;\n dcts?: string;\n cjs?: string;\n raw?: string;\n};\n\ntype BuildResult = {\n exportsMap: Map<string, ExportsObject>;\n binsMap: Map<string, string>;\n};\n\ntype ExportsPackageJsonObj =\n | {\n import?: ExportsPackageJsonObj;\n require?: ExportsPackageJsonObj;\n types?: string;\n default?: string;\n }\n | string;\n\nfunction extractValue(value?: ExportsPackageJsonObj) {\n if (!value) {\n return undefined;\n }\n if (typeof value === \"string\") {\n return value;\n }\n return value.default;\n}\n\nexport async function writePackageJson(\n outDir: string,\n parsed: PackageJson,\n { exportsMap, binsMap }: BuildResult,\n) {\n // we always want to have `exports` property in the target package.json\n // If you want to export something, please, specify them\n const allExports: Record<string, ExportsPackageJsonObj> = {};\n for (const [key, value] of exportsMap) {\n const anExport: ExportsPackageJsonObj = {};\n\n if (value.mjs) {\n anExport.import = {};\n if (value.dmts) {\n anExport.import.types = value.dmts;\n }\n anExport.import.default = value.mjs;\n }\n if (value.cjs) {\n anExport.require = {};\n if (value.dcts) {\n anExport.require.types = value.dcts;\n }\n anExport.require.default = value.cjs;\n }\n\n // should be first for correct resolving\n anExport.types = value.dcts ?? value.dmts;\n // because we need to have default and types key on the end\n // JSON.stringify will put it on the end if we put value at the last step\n anExport.default = value.cjs;\n\n allExports[key] = anExport;\n }\n allExports[\"./package.json\"] = \"./package.json\";\n\n const bin = binsMap.size > 0 ? Object.fromEntries(binsMap) : undefined;\n\n const rootExport =\n typeof allExports[\".\"] === \"object\" ? allExports[\".\"] : undefined;\n\n parsed = convertPackageJson(parsed);\n\n const res = {\n name: parsed.name,\n type: \"commonjs\",\n version: parsed.version,\n bin,\n types: rootExport?.types,\n module: extractValue(rootExport?.import),\n main: extractValue(rootExport?.require),\n description: parsed.description ?? \"\",\n exports: allExports,\n dependencies: parsed.dependencies ?? undefined,\n optionalDependencies: parsed.optionalDependencies ?? undefined,\n repository: parsed.repository,\n keywords: parsed.keywords,\n author: parsed.author,\n contributors: parsed.contributors,\n license: parsed.license,\n peerDependencies: parsed.peerDependencies,\n engines: parsed.engines,\n browser: parsed.browser,\n funding: parsed.funding,\n os: parsed.os,\n cpu: parsed.cpu,\n maintainers: parsed.maintainers,\n bugs: parsed.bugs,\n sideEffects: parsed.sideEffects,\n unpkg: parsed.unpkg,\n homepage: parsed.homepage,\n devDependencies: parsed.devDependencies,\n peerDependenciesMeta: parsed.peerDependenciesMeta,\n };\n\n await writeFile(`${outDir}/package.json`, JSON.stringify(res, null, 2));\n\n okLog(\"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C,sBAAsB,OAAO,wBAAwB;AAAA,IACrD,YAAY,OAAO;AAAA,IACnB,UAAU,OAAO;AAAA,IACjB,QAAQ,OAAO;AAAA,IACf,cAAc,OAAO;AAAA,IACrB,SAAS,OAAO;AAAA,IAChB,kBAAkB,OAAO;AAAA,IACzB,SAAS,OAAO;AAAA,IAChB,SAAS,OAAO;AAAA,IAChB,SAAS,OAAO;AAAA,IAChB,IAAI,OAAO;AAAA,IACX,KAAK,OAAO;AAAA,IACZ,aAAa,OAAO;AAAA,IACpB,MAAM,OAAO;AAAA,IACb,aAAa,OAAO;AAAA,IACpB,OAAO,OAAO;AAAA,IACd,UAAU,OAAO;AAAA,IACjB,iBAAiB,OAAO;AAAA,IACxB,sBAAsB,OAAO;AAAA,EAC/B;AAEM,QAAAC,aAAU,GAAG,MAAM,iBAAiB,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC;AAEtEC,MAAAA,MAAM,cAAc;AACtB;;"}
|
@@ -4,6 +4,7 @@ export declare const args: {
|
|
4
4
|
packagePath: string;
|
5
5
|
outputDir: string;
|
6
6
|
seq: boolean;
|
7
|
+
ci: boolean;
|
7
8
|
_: (string | number)[];
|
8
9
|
$0: string;
|
9
10
|
};
|
@@ -15,5 +16,12 @@ type ConvertUndefinedToOptional<T> = {
|
|
15
16
|
} & {
|
16
17
|
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
|
17
18
|
};
|
18
|
-
export type
|
19
|
+
export type Monorepo = {
|
20
|
+
type: "pnpm";
|
21
|
+
devDeps: Record<string, string>;
|
22
|
+
};
|
23
|
+
export type Args = ConvertUndefinedToOptional<Omit<OmitUnknown<typeof args>, "_" | "$0">> & {
|
24
|
+
monorepo?: Monorepo;
|
25
|
+
skipGitignore?: boolean;
|
26
|
+
};
|
19
27
|
export {};
|
@@ -16,6 +16,9 @@ const argsSchema = yargs().option("sourceDir", {
|
|
16
16
|
}).option("seq", {
|
17
17
|
type: "boolean",
|
18
18
|
describe: "run internal tasks sequentially. It is useful for performance testing and debugging. This option is unstable and not recommended for production use."
|
19
|
+
}).option("ci", {
|
20
|
+
type: "boolean",
|
21
|
+
describe: "run in CI mode"
|
19
22
|
}).help("help");
|
20
23
|
const args = argsSchema.parseSync(hideBin(process.argv));
|
21
24
|
export {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"args.mjs","sources":["../../../../src/args.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport * as process from \"node:process\";\nimport { hideBin } from \"yargs/helpers\";\n\nconst argsSchema = yargs()\n .option(\"sourceDir\", {\n alias: \"s\",\n type: \"string\",\n describe:\n \"path to the project directory. Default: current working directory\",\n })\n .option(\"packagePath\", {\n alias: \"p\",\n type: \"string\",\n describe: \"path to the package.json. Default: cwd()/package.json\",\n })\n .option(\"outputDir\", {\n alias: \"o\",\n type: \"string\",\n describe: \"path to the output directory. Default: cwd()/dist\",\n })\n // Do not cover this option in tests because it is unstable\n .option(\"seq\", {\n type: \"boolean\",\n describe:\n \"run internal tasks sequentially. It is useful for performance testing and debugging. This option is unstable and not recommended for production use.\",\n })\n .help(\"help\");\n\nexport const args = argsSchema.parseSync(hideBin(process.argv));\n\ntype OmitUnknown<T> = {\n [K in keyof T as string extends K ? never : K]: T[K];\n};\ntype ConvertUndefinedToOptional<T> = {\n [K in keyof T as undefined extends T[K] ? K : never]?: Exclude<\n T[K],\n undefined\n >;\n} & {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K];\n};\n\nexport type Args = ConvertUndefinedToOptional<\n Omit<OmitUnknown<typeof args>, \"_\" | \"$0\">\n
|
1
|
+
{"version":3,"file":"args.mjs","sources":["../../../../src/args.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport * as process from \"node:process\";\nimport { hideBin } from \"yargs/helpers\";\n\nconst argsSchema = yargs()\n .option(\"sourceDir\", {\n alias: \"s\",\n type: \"string\",\n describe:\n \"path to the project directory. Default: current working directory\",\n })\n .option(\"packagePath\", {\n alias: \"p\",\n type: \"string\",\n describe: \"path to the package.json. Default: cwd()/package.json\",\n })\n .option(\"outputDir\", {\n alias: \"o\",\n type: \"string\",\n describe: \"path to the output directory. Default: cwd()/dist\",\n })\n // Do not cover this option in tests because it is unstable\n .option(\"seq\", {\n type: \"boolean\",\n describe:\n \"run internal tasks sequentially. It is useful for performance testing and debugging. This option is unstable and not recommended for production use.\",\n })\n .option(\"ci\", {\n type: \"boolean\",\n describe: \"run in CI mode\",\n })\n .help(\"help\");\n\nexport const args = argsSchema.parseSync(hideBin(process.argv));\n\ntype OmitUnknown<T> = {\n [K in keyof T as string extends K ? never : K]: T[K];\n};\ntype ConvertUndefinedToOptional<T> = {\n [K in keyof T as undefined extends T[K] ? K : never]?: Exclude<\n T[K],\n undefined\n >;\n} & {\n [K in keyof T as undefined extends T[K] ? never : K]: T[K];\n};\n\nexport type Monorepo = {\n type: \"pnpm\";\n devDeps: Record<string, string>;\n};\n\nexport type Args = ConvertUndefinedToOptional<\n Omit<OmitUnknown<typeof args>, \"_\" | \"$0\">\n> & {\n monorepo?: Monorepo;\n skipGitignore?: boolean;\n};\n"],"names":[],"mappings":";;;AAIA,MAAM,aAAa,MAAA,EAChB,OAAO,aAAa;AAAA,EACnB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UACE;AACJ,CAAC,EACA,OAAO,eAAe;AAAA,EACrB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AACZ,CAAC,EACA,OAAO,aAAa;AAAA,EACnB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,UAAU;AACZ,CAAC,EAEA,OAAO,OAAO;AAAA,EACb,MAAM;AAAA,EACN,UACE;AACJ,CAAC,EACA,OAAO,MAAM;AAAA,EACZ,MAAM;AAAA,EACN,UAAU;AACZ,CAAC,EACA,KAAK,MAAM;AAEP,MAAM,OAAO,WAAW,UAAU,QAAQ,QAAQ,IAAI,CAAC;"}
|
@@ -1,23 +1,37 @@
|
|
1
1
|
import { type PackageJson } from "./packageJson.js";
|
2
2
|
import semver from "semver";
|
3
3
|
import type { Dirs } from "./resolveDirs.js";
|
4
|
-
|
4
|
+
import type { Monorepo } from "./args.js";
|
5
|
+
type ModuleWithVersion<T> = T & {
|
6
|
+
version: string;
|
7
|
+
};
|
8
|
+
type TSModuleData = {
|
5
9
|
ts: typeof import("typescript");
|
6
10
|
parsedConfig: import("typescript").ParsedCommandLine;
|
7
11
|
host: import("typescript").CompilerHost;
|
8
12
|
};
|
13
|
+
type BabelModuleData = {
|
14
|
+
babel: typeof import("@babel/core");
|
15
|
+
};
|
16
|
+
type ReactModuleData = {
|
17
|
+
transform: "legacy" | "modern";
|
18
|
+
};
|
19
|
+
export type TSModule = ModuleWithVersion<TSModuleData>;
|
20
|
+
export type BabelModule = ModuleWithVersion<BabelModuleData>;
|
21
|
+
export type ReactModule = ModuleWithVersion<ReactModuleData>;
|
9
22
|
export type DetectedModules = {
|
10
|
-
ts?:
|
11
|
-
babel?:
|
12
|
-
react?:
|
23
|
+
ts?: TSModule;
|
24
|
+
babel?: BabelModule;
|
25
|
+
react?: ReactModule;
|
13
26
|
};
|
14
|
-
type
|
15
|
-
|
16
|
-
export declare function detectModules(packageJson: PackageJson, dirs: Dirs): Promise<{
|
17
|
-
error: false;
|
27
|
+
export type DetectModulesResult = {
|
28
|
+
success: true;
|
18
29
|
modules: DetectedModules;
|
19
30
|
} | {
|
20
|
-
|
21
|
-
errors:
|
22
|
-
}
|
31
|
+
success: false;
|
32
|
+
errors: string[];
|
33
|
+
};
|
34
|
+
type DepType = "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies";
|
35
|
+
export declare function getMinVersion(packageJson: PackageJson, depName: string, exclude: DepType[]): semver.SemVer | null;
|
36
|
+
export declare function detectModules(packageJson: PackageJson, dirs: Dirs, monorepo?: Monorepo): Promise<DetectModulesResult>;
|
23
37
|
export {};
|
@@ -35,20 +35,59 @@ function getMinVersion(packageJson, depName, exclude) {
|
|
35
35
|
}
|
36
36
|
return minVersion;
|
37
37
|
}
|
38
|
-
async function detectBabel(packageJson) {
|
38
|
+
async function detectBabel(packageJson, isMonorepoPackage) {
|
39
|
+
const hasBabelInPackage = getMinVersion(packageJson, "@babel/core", [
|
40
|
+
"optionalDependencies"
|
41
|
+
]);
|
42
|
+
if (isMonorepoPackage && hasBabelInPackage) {
|
43
|
+
return {
|
44
|
+
success: false,
|
45
|
+
error: `Babel found in package-level package.json for monorepo package "${packageJson.name}".
|
46
|
+
In monorepos, build tools like Babel should be defined in the workspace root package.json, not in individual packages.
|
47
|
+
Please move "@babel/core" from this package's dependencies/devDependencies to the root package.json's devDependencies.`
|
48
|
+
};
|
49
|
+
}
|
39
50
|
if ("@babel/core" in (packageJson.optionalDependencies ?? {})) {
|
40
51
|
errorLog("babel excluded because inside optionalDependencies");
|
41
|
-
return
|
52
|
+
return {
|
53
|
+
success: false,
|
54
|
+
error: "Babel excluded because it's in optionalDependencies"
|
55
|
+
};
|
56
|
+
}
|
57
|
+
const babelVersion = getMinVersion(packageJson, "@babel/core", [
|
58
|
+
"optionalDependencies"
|
59
|
+
]);
|
60
|
+
if (!babelVersion) {
|
61
|
+
errorLog("babel");
|
62
|
+
return { success: true, module: void 0 };
|
42
63
|
}
|
43
64
|
try {
|
44
65
|
const babel = await import("@babel/core");
|
45
66
|
okLog("babel, version:", babel.version);
|
46
|
-
return
|
67
|
+
return {
|
68
|
+
success: true,
|
69
|
+
module: {
|
70
|
+
babel,
|
71
|
+
version: babel.version
|
72
|
+
}
|
73
|
+
};
|
47
74
|
} catch {
|
48
75
|
errorLog("babel");
|
76
|
+
return { success: false, error: "Failed to import @babel/core" };
|
49
77
|
}
|
50
78
|
}
|
51
|
-
async function detectReact(packageJson) {
|
79
|
+
async function detectReact(packageJson, isMonorepoPackage) {
|
80
|
+
const reactVersionInPackage = getMinVersion(packageJson, "react", [
|
81
|
+
"devDependencies"
|
82
|
+
]);
|
83
|
+
if (isMonorepoPackage && reactVersionInPackage) {
|
84
|
+
return {
|
85
|
+
success: false,
|
86
|
+
error: `React found in package-level package.json for monorepo package "${packageJson.name}".
|
87
|
+
In monorepos, build tools like React should be defined in the workspace root package.json, not in individual packages.
|
88
|
+
Please move "react" from this package's dependencies/peerDependencies to the root package.json's dependencies or peerDependencies.`
|
89
|
+
};
|
90
|
+
}
|
52
91
|
const reactVersion = getMinVersion(packageJson, "react", ["devDependencies"]);
|
53
92
|
if (reactVersion) {
|
54
93
|
const isLegacy = semver.lt(reactVersion, "17.0.0");
|
@@ -56,29 +95,58 @@ async function detectReact(packageJson) {
|
|
56
95
|
okLog(
|
57
96
|
`react, min version: ${reactVersion.version}. Transform: ${transform}`
|
58
97
|
);
|
59
|
-
return
|
98
|
+
return {
|
99
|
+
success: true,
|
100
|
+
module: {
|
101
|
+
transform,
|
102
|
+
version: reactVersion.version
|
103
|
+
}
|
104
|
+
};
|
60
105
|
}
|
61
106
|
errorLog("react");
|
107
|
+
return { success: true, module: void 0 };
|
62
108
|
}
|
63
|
-
async function detectTypescript(packageJson, dirs) {
|
109
|
+
async function detectTypescript(packageJson, dirs, monorepoType) {
|
64
110
|
const typescriptVersion = getMinVersion(packageJson, "typescript", []);
|
111
|
+
if (monorepoType != null && typescriptVersion) {
|
112
|
+
return {
|
113
|
+
success: false,
|
114
|
+
error: `TypeScript found in package-level package.json for monorepo package "${packageJson.name}".
|
115
|
+
In monorepos, build tools like TypeScript should be defined in the workspace root package.json, not in individual packages.
|
116
|
+
Please move "typescript" from this package's dependencies/devDependencies to the root package.json's devDependencies.`
|
117
|
+
};
|
118
|
+
}
|
65
119
|
if (!typescriptVersion) {
|
66
120
|
errorLog("typescript");
|
67
|
-
return;
|
121
|
+
return { success: true, module: void 0 };
|
68
122
|
}
|
69
123
|
let ts;
|
70
124
|
try {
|
71
125
|
ts = (await import("typescript")).default;
|
72
126
|
} catch {
|
73
|
-
|
74
|
-
|
127
|
+
if (monorepoType === "pnpm") {
|
128
|
+
return {
|
129
|
+
success: false,
|
130
|
+
error: `smartbundle found the .ts entrypoint but required "typescript" to build .d.ts files. Please install the "typescript" dependency. In pnpm workspaces, you may need to either:
|
131
|
+
1. Add "hoist-workspace-packages=true" to your pnpm-workspace.yaml file (recommended), or
|
132
|
+
2. Add "public-hoist-pattern[]=[\\"typescript\\"]" to your pnpm-workspace.yaml file, or
|
133
|
+
3. Add "typescript" as a devDependency in each package's package.json
|
134
|
+
See https://pnpm.io/settings#dependency-hoisting-settings for more details.`
|
135
|
+
};
|
136
|
+
} else {
|
137
|
+
return {
|
138
|
+
success: false,
|
139
|
+
error: 'smartbundle found the .ts entrypoint but required "typescript" to build .d.ts files. Please install the "typescript" dependency.'
|
140
|
+
};
|
141
|
+
}
|
75
142
|
}
|
76
143
|
okLog("typescript, version:", ts.version);
|
77
144
|
const configFilePath = ts.findConfigFile(dirs.sourceDir, ts.sys.fileExists);
|
78
145
|
if (!configFilePath) {
|
79
|
-
|
80
|
-
|
81
|
-
|
146
|
+
return {
|
147
|
+
success: false,
|
148
|
+
error: "Cannot find a tsconfig.json file. You should declare it. Please, read the https://github.com/XaveScor/smartbundle/issues/131 for more information"
|
149
|
+
};
|
82
150
|
}
|
83
151
|
const configFile = ts.readConfigFile(configFilePath, ts.sys.readFile);
|
84
152
|
if (configFile.error) {
|
@@ -86,7 +154,10 @@ async function detectTypescript(packageJson, dirs) {
|
|
86
154
|
configFile.error.messageText,
|
87
155
|
"\n"
|
88
156
|
);
|
89
|
-
|
157
|
+
return {
|
158
|
+
success: false,
|
159
|
+
error: `Cannot read tsconfig.json file, error: ${readableError}`
|
160
|
+
};
|
90
161
|
}
|
91
162
|
const parsedConfig = ts.parseJsonConfigFileContent(
|
92
163
|
configFile.config,
|
@@ -108,25 +179,91 @@ async function detectTypescript(packageJson, dirs) {
|
|
108
179
|
configFilePath
|
109
180
|
);
|
110
181
|
if (!parsedConfig.options.verbatimModuleSyntax) {
|
111
|
-
|
112
|
-
|
113
|
-
|
182
|
+
return {
|
183
|
+
success: false,
|
184
|
+
error: "verbatimModuleSyntax should be enabled in tsconfig.json. Read https://github.com/XaveScor/smartbundle/issues/131 for more explanation.\nYou also can upvote the issue if you need the support of verbatimModuleSyntax: false in your library"
|
185
|
+
};
|
114
186
|
}
|
115
187
|
const host = ts.createCompilerHost(parsedConfig.options);
|
116
|
-
return {
|
188
|
+
return {
|
189
|
+
success: true,
|
190
|
+
module: {
|
191
|
+
ts,
|
192
|
+
parsedConfig,
|
193
|
+
host,
|
194
|
+
version: ts.version
|
195
|
+
}
|
196
|
+
};
|
117
197
|
}
|
118
|
-
async function detectModules(packageJson, dirs) {
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
198
|
+
async function detectModules(packageJson, dirs, monorepo) {
|
199
|
+
if (!monorepo) {
|
200
|
+
return detectPackageModules(packageJson, dirs);
|
201
|
+
}
|
202
|
+
const packageValidation = await detectPackageModules(
|
203
|
+
packageJson,
|
204
|
+
dirs,
|
205
|
+
monorepo.type
|
206
|
+
);
|
207
|
+
const errors = [];
|
208
|
+
if (!packageValidation.success) {
|
209
|
+
errors.push(...packageValidation.errors);
|
210
|
+
} else {
|
211
|
+
if (packageValidation.modules.ts) {
|
212
|
+
errors.push(
|
213
|
+
`Package "${packageJson.name}" has ts/babel in package.json, but it's not allowed in monorepo.`
|
214
|
+
);
|
215
|
+
}
|
216
|
+
if (packageValidation.modules.babel) {
|
217
|
+
errors.push(
|
218
|
+
`Package "${packageJson.name}" has babel in package.json, but it's not allowed in monorepo.`
|
219
|
+
);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
const mergedPackageJson = {
|
223
|
+
...packageJson,
|
224
|
+
devDependencies: {
|
225
|
+
...monorepo.devDeps,
|
226
|
+
...packageJson.devDependencies
|
227
|
+
}
|
228
|
+
};
|
229
|
+
const result = await detectPackageModules(mergedPackageJson, dirs);
|
230
|
+
if (!result.success) {
|
231
|
+
errors.push(...result.errors);
|
232
|
+
}
|
233
|
+
if (errors.length > 0) {
|
234
|
+
return { success: false, errors };
|
235
|
+
}
|
236
|
+
return result;
|
237
|
+
}
|
238
|
+
async function detectPackageModules(packageJson, dirs, monorepoType) {
|
239
|
+
log("Detecting modules");
|
240
|
+
const [tsResult, babelResult, reactResult] = await Promise.all([
|
241
|
+
detectTypescript(packageJson, dirs, monorepoType),
|
242
|
+
detectBabel(packageJson, monorepoType != null),
|
243
|
+
detectReact(packageJson, monorepoType != null)
|
244
|
+
]);
|
245
|
+
const errors = [];
|
246
|
+
const modules = {};
|
247
|
+
if (!tsResult.success) {
|
248
|
+
errors.push(tsResult.error);
|
249
|
+
} else if (tsResult.module) {
|
250
|
+
modules.ts = tsResult.module;
|
251
|
+
}
|
252
|
+
if (!babelResult.success) {
|
253
|
+
errors.push(babelResult.error);
|
254
|
+
} else if (babelResult.module) {
|
255
|
+
modules.babel = babelResult.module;
|
256
|
+
}
|
257
|
+
if (!reactResult.success) {
|
258
|
+
errors.push(reactResult.error);
|
259
|
+
} else if (reactResult.module) {
|
260
|
+
modules.react = reactResult.module;
|
261
|
+
}
|
262
|
+
lineLog();
|
263
|
+
if (errors.length > 0) {
|
264
|
+
return { success: false, errors };
|
129
265
|
}
|
266
|
+
return { success: true, modules };
|
130
267
|
}
|
131
268
|
export {
|
132
269
|
detectModules,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"detectModules.mjs","sources":["../../../../src/detectModules.ts"],"sourcesContent":["import { type PackageJson } from \"./packageJson.js\";\nimport semver from \"semver\";\nimport { okLog, errorLog, log, lineLog, warnLog } from \"./log.js\";\nimport type { Dirs } from \"./resolveDirs.js\";\n\nexport type TS = {\n ts: typeof import(\"typescript\");\n parsedConfig: import(\"typescript\").ParsedCommandLine;\n host: import(\"typescript\").CompilerHost;\n};\nexport type DetectedModules = {\n ts?: TS;\n babel?: typeof import(\"@babel/core\");\n react?: \"legacy\" | \"modern\";\n};\n\ntype DepType =\n | \"dependencies\"\n | \"devDependencies\"\n | \"peerDependencies\"\n | \"optionalDependencies\";\nexport function getMinVersion(\n packageJson: PackageJson,\n depName: string,\n exclude: DepType[],\n): semver.SemVer | null {\n const allDepKeys = new Set<DepType>([\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n ]);\n for (const e of exclude) {\n allDepKeys.delete(e);\n }\n\n let minVersion: semver.SemVer | null = null;\n for (const depKey of allDepKeys) {\n const depVersion = packageJson[depKey]?.[depName];\n if (depVersion) {\n const version = semver.minVersion(depVersion);\n if (!version) {\n warnLog(\"node-semver cannot parse version of\", depName, \"from\", depKey);\n warnLog(\"Version:\", depVersion);\n continue;\n }\n if (!minVersion) {\n minVersion = version;\n continue;\n }\n if (semver.lt(version, minVersion)) {\n minVersion = version;\n }\n }\n }\n\n return minVersion;\n}\n\nasync function detectBabel(\n packageJson: PackageJson,\n): Promise<typeof import(\"@babel/core\") | undefined> {\n if (\"@babel/core\" in (packageJson.optionalDependencies ?? {})) {\n errorLog(\"babel excluded because inside optionalDependencies\");\n return;\n }\n\n try {\n const babel = await import(\"@babel/core\");\n okLog(\"babel, version:\", babel.version);\n return babel;\n } catch {\n errorLog(\"babel\");\n }\n}\n\nasync function detectReact(\n packageJson: PackageJson,\n): Promise<\"legacy\" | \"modern\" | undefined> {\n const reactVersion = getMinVersion(packageJson, \"react\", [\"devDependencies\"]);\n if (reactVersion) {\n const isLegacy = semver.lt(reactVersion, \"17.0.0\");\n const transform = isLegacy ? \"legacy\" : \"modern\";\n okLog(\n `react, min version: ${reactVersion.version}. Transform: ${transform}`,\n );\n return transform;\n }\n errorLog(\"react\");\n}\n\nasync function detectTypescript(\n packageJson: PackageJson,\n dirs: Dirs,\n): Promise<TS | undefined> {\n const typescriptVersion = getMinVersion(packageJson, \"typescript\", []);\n if (!typescriptVersion) {\n errorLog(\"typescript\");\n return;\n }\n\n let ts: typeof import(\"typescript\");\n try {\n // ts <=4.3 has no named exports. The all methods is located in the default export\n ts = (await import(\"typescript\")).default;\n } catch {\n errorLog(\"typescript\");\n return;\n }\n\n okLog(\"typescript, version:\", ts.version);\n\n const configFilePath = ts.findConfigFile(dirs.sourceDir, ts.sys.fileExists);\n if (!configFilePath) {\n throw new Error(\n \"Cannot find a tsconfig.json file. You should declare it. Please, read the https://github.com/XaveScor/smartbundle/issues/131 for more information\",\n );\n }\n const configFile = ts.readConfigFile(configFilePath, ts.sys.readFile);\n if (configFile.error) {\n const readableError = ts.flattenDiagnosticMessageText(\n configFile.error.messageText,\n \"\\n\",\n );\n throw new Error(`Cannot read tsconfig.json file, error: ${readableError}`);\n }\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n dirs.sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n outDir: \"\",\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configFilePath,\n );\n\n if (!parsedConfig.options.verbatimModuleSyntax) {\n throw new Error(\n \"verbatimModuleSyntax should be enabled in tsconfig.json. Read https://github.com/XaveScor/smartbundle/issues/131 for more explanation.\\n\" +\n \"You also can upvote the issue if you need the support of verbatimModuleSyntax: false in your library\",\n );\n }\n\n const host = ts.createCompilerHost(parsedConfig.options);\n\n return { ts, parsedConfig, host };\n}\n\nexport async function detectModules(\n packageJson: PackageJson,\n dirs: Dirs,\n): Promise<\n | { error: false; modules: DetectedModules }\n | { error: true; errors: Array<string> }\n> {\n try {\n const result: DetectedModules = {};\n log(\"Detecting modules\");\n\n result.ts = await detectTypescript(packageJson, dirs);\n result.babel = await detectBabel(packageJson);\n result.react = await detectReact(packageJson);\n\n lineLog();\n return { error: false, modules: result };\n } catch (e: any) {\n return { error: true, errors: [e.message] };\n }\n}\n"],"names":[],"mappings":";;;;;AAqBgB,SAAA,cACd,aACA,SACA,SACsB;;AAChB,QAAA,iCAAiB,IAAa;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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,OAAO,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE;AAAA,EAAA;AAE9C;"}
|
1
|
+
{"version":3,"file":"detectModules.mjs","sources":["../../../../src/detectModules.ts"],"sourcesContent":["import { type PackageJson } from \"./packageJson.js\";\nimport semver from \"semver\";\nimport { okLog, errorLog, log, lineLog, warnLog } from \"./log.js\";\nimport type { Dirs } from \"./resolveDirs.js\";\nimport type { Monorepo } from \"./args.js\";\n\ntype DetectionResult<T> =\n // We have undefined here is module is not found\n // It is not an error because the user would disable some functionality by not installing deps\n { success: true; module: T | undefined } | { success: false; error: string };\n\ntype ModuleWithVersion<T> = T & { version: string };\n\ntype TSModuleData = {\n ts: typeof import(\"typescript\");\n parsedConfig: import(\"typescript\").ParsedCommandLine;\n host: import(\"typescript\").CompilerHost;\n};\n\ntype BabelModuleData = {\n babel: typeof import(\"@babel/core\");\n};\n\ntype ReactModuleData = {\n transform: \"legacy\" | \"modern\";\n};\n\nexport type TSModule = ModuleWithVersion<TSModuleData>;\nexport type BabelModule = ModuleWithVersion<BabelModuleData>;\nexport type ReactModule = ModuleWithVersion<ReactModuleData>;\n\nexport type DetectedModules = {\n ts?: TSModule;\n babel?: BabelModule;\n react?: ReactModule;\n};\n\nexport type DetectModulesResult =\n | { success: true; modules: DetectedModules }\n | { success: false; errors: string[] };\n\ntype DepType =\n | \"dependencies\"\n | \"devDependencies\"\n | \"peerDependencies\"\n | \"optionalDependencies\";\nexport function getMinVersion(\n packageJson: PackageJson,\n depName: string,\n exclude: DepType[],\n): semver.SemVer | null {\n const allDepKeys = new Set<DepType>([\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n ]);\n for (const e of exclude) {\n allDepKeys.delete(e);\n }\n\n let minVersion: semver.SemVer | null = null;\n\n for (const depKey of allDepKeys) {\n const depVersion = packageJson[depKey]?.[depName];\n if (depVersion) {\n const version = semver.minVersion(depVersion);\n if (!version) {\n warnLog(\"node-semver cannot parse version of\", depName, \"from\", depKey);\n warnLog(\"Version:\", depVersion);\n continue;\n }\n if (!minVersion) {\n minVersion = version;\n continue;\n }\n if (semver.lt(version, minVersion)) {\n minVersion = version;\n }\n }\n }\n\n return minVersion;\n}\n\nasync function detectBabel(\n packageJson: PackageJson,\n isMonorepoPackage: boolean,\n): Promise<DetectionResult<BabelModule>> {\n const hasBabelInPackage = getMinVersion(packageJson, \"@babel/core\", [\n \"optionalDependencies\",\n ]);\n\n if (isMonorepoPackage && hasBabelInPackage) {\n return {\n success: false,\n error:\n `Babel found in package-level package.json for monorepo package \"${packageJson.name}\".\\n` +\n `In monorepos, build tools like Babel should be defined in the workspace root package.json, not in individual packages.\\n` +\n `Please move \"@babel/core\" from this package's dependencies/devDependencies to the root package.json's devDependencies.`,\n };\n }\n\n if (\"@babel/core\" in (packageJson.optionalDependencies ?? {})) {\n errorLog(\"babel excluded because inside optionalDependencies\");\n return {\n success: false,\n error: \"Babel excluded because it's in optionalDependencies\",\n };\n }\n\n // Check for babel in package deps\n const babelVersion = getMinVersion(packageJson, \"@babel/core\", [\n \"optionalDependencies\",\n ]);\n\n if (!babelVersion) {\n errorLog(\"babel\");\n return { success: true, module: undefined };\n }\n\n try {\n const babel = await import(\"@babel/core\");\n okLog(\"babel, version:\", babel.version);\n return {\n success: true,\n module: {\n babel,\n version: babel.version,\n },\n };\n } catch {\n errorLog(\"babel\");\n return { success: false, error: \"Failed to import @babel/core\" };\n }\n}\n\nasync function detectReact(\n packageJson: PackageJson,\n isMonorepoPackage: boolean,\n): Promise<DetectionResult<ReactModule>> {\n const reactVersionInPackage = getMinVersion(packageJson, \"react\", [\n \"devDependencies\",\n ]);\n\n if (isMonorepoPackage && reactVersionInPackage) {\n return {\n success: false,\n error:\n `React found in package-level package.json for monorepo package \"${packageJson.name}\".\\n` +\n `In monorepos, build tools like React should be defined in the workspace root package.json, not in individual packages.\\n` +\n `Please move \"react\" from this package's dependencies/peerDependencies to the root package.json's dependencies or peerDependencies.`,\n };\n }\n\n const reactVersion = getMinVersion(packageJson, \"react\", [\"devDependencies\"]);\n\n if (reactVersion) {\n const isLegacy = semver.lt(reactVersion, \"17.0.0\");\n const transform = isLegacy ? \"legacy\" : \"modern\";\n okLog(\n `react, min version: ${reactVersion.version}. Transform: ${transform}`,\n );\n return {\n success: true,\n module: {\n transform,\n version: reactVersion.version,\n },\n };\n }\n\n errorLog(\"react\");\n return { success: true, module: undefined };\n}\n\nasync function detectTypescript(\n packageJson: PackageJson,\n dirs: Dirs,\n monorepoType?: \"pnpm\" | null,\n): Promise<DetectionResult<TSModule>> {\n const typescriptVersion = getMinVersion(packageJson, \"typescript\", []);\n\n if (monorepoType != null && typescriptVersion) {\n return {\n success: false,\n error:\n `TypeScript found in package-level package.json for monorepo package \"${packageJson.name}\".\\n` +\n `In monorepos, build tools like TypeScript should be defined in the workspace root package.json, not in individual packages.\\n` +\n `Please move \"typescript\" from this package's dependencies/devDependencies to the root package.json's devDependencies.`,\n };\n }\n\n if (!typescriptVersion) {\n errorLog(\"typescript\");\n return { success: true, module: undefined };\n }\n\n let ts: typeof import(\"typescript\");\n try {\n // ts <=4.3 has no named exports. The all methods are located in the default export\n ts = (await import(\"typescript\")).default;\n } catch {\n if (monorepoType === \"pnpm\") {\n return {\n success: false,\n error:\n 'smartbundle found the .ts entrypoint but required \"typescript\" to build .d.ts files. ' +\n 'Please install the \"typescript\" dependency. ' +\n \"In pnpm workspaces, you may need to either:\\n\" +\n '1. Add \"hoist-workspace-packages=true\" to your pnpm-workspace.yaml file (recommended), or\\n' +\n '2. Add \"public-hoist-pattern[]=[\\\\\"typescript\\\\\"]\" to your pnpm-workspace.yaml file, or\\n' +\n '3. Add \"typescript\" as a devDependency in each package\\'s package.json\\n' +\n \"See https://pnpm.io/settings#dependency-hoisting-settings for more details.\",\n };\n } else {\n return {\n success: false,\n error:\n 'smartbundle found the .ts entrypoint but required \"typescript\" to build .d.ts files. ' +\n 'Please install the \"typescript\" dependency.',\n };\n }\n }\n\n okLog(\"typescript, version:\", ts.version);\n\n const configFilePath = ts.findConfigFile(dirs.sourceDir, ts.sys.fileExists);\n if (!configFilePath) {\n return {\n success: false,\n error:\n \"Cannot find a tsconfig.json file. You should declare it. Please, read the https://github.com/XaveScor/smartbundle/issues/131 for more information\",\n };\n }\n const configFile = ts.readConfigFile(configFilePath, ts.sys.readFile);\n if (configFile.error) {\n const readableError = ts.flattenDiagnosticMessageText(\n configFile.error.messageText,\n \"\\n\",\n );\n return {\n success: false,\n error: `Cannot read tsconfig.json file, error: ${readableError}`,\n };\n }\n const parsedConfig = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n dirs.sourceDir,\n {\n declaration: true,\n emitDeclarationOnly: true,\n strict: false,\n strictNullChecks: false,\n strictFunctionTypes: false,\n strictPropertyInitialization: false,\n skipLibCheck: true,\n skipDefaultLibCheck: true,\n outDir: \"\",\n // https://github.com/XaveScor/bobrik/issues/22#issuecomment-2308552352\n noEmit: false,\n },\n configFilePath,\n );\n\n if (!parsedConfig.options.verbatimModuleSyntax) {\n return {\n success: false,\n error:\n \"verbatimModuleSyntax should be enabled in tsconfig.json. Read https://github.com/XaveScor/smartbundle/issues/131 for more explanation.\\n\" +\n \"You also can upvote the issue if you need the support of verbatimModuleSyntax: false in your library\",\n };\n }\n\n const host = ts.createCompilerHost(parsedConfig.options);\n\n return {\n success: true,\n module: {\n ts,\n parsedConfig,\n host,\n version: ts.version,\n },\n };\n}\n\nexport async function detectModules(\n packageJson: PackageJson,\n dirs: Dirs,\n monorepo?: Monorepo,\n): Promise<DetectModulesResult> {\n if (!monorepo) {\n return detectPackageModules(packageJson, dirs);\n }\n\n // First, check if package has ts/babel (which is wrong in monorepo)\n const packageValidation = await detectPackageModules(\n packageJson,\n dirs,\n monorepo.type,\n );\n\n // Collect validation errors\n const errors: string[] = [];\n if (!packageValidation.success) {\n errors.push(...packageValidation.errors);\n } else {\n if (packageValidation.modules.ts) {\n errors.push(\n `Package \"${packageJson.name}\" has ts/babel in package.json, but it's not allowed in monorepo.`,\n );\n }\n if (packageValidation.modules.babel) {\n errors.push(\n `Package \"${packageJson.name}\" has babel in package.json, but it's not allowed in monorepo.`,\n );\n }\n }\n\n // Create merged package.json with workspace devDeps for ts/babel\n const mergedPackageJson: PackageJson = {\n ...packageJson,\n devDependencies: {\n ...monorepo.devDeps,\n ...packageJson.devDependencies,\n },\n };\n\n // Detect modules with merged package.json (ts/babel from workspace, react from package)\n const result = await detectPackageModules(mergedPackageJson, dirs);\n\n if (!result.success) {\n errors.push(...result.errors);\n }\n\n if (errors.length > 0) {\n return { success: false, errors };\n }\n\n return result;\n}\n\nasync function detectPackageModules(\n packageJson: PackageJson,\n dirs: Dirs,\n monorepoType?: \"pnpm\" | null,\n): Promise<DetectModulesResult> {\n log(\"Detecting modules\");\n\n const [tsResult, babelResult, reactResult] = await Promise.all([\n detectTypescript(packageJson, dirs, monorepoType),\n detectBabel(packageJson, monorepoType != null),\n detectReact(packageJson, monorepoType != null),\n ]);\n\n const errors: string[] = [];\n const modules: DetectedModules = {};\n\n if (!tsResult.success) {\n errors.push(tsResult.error);\n } else if (tsResult.module) {\n modules.ts = tsResult.module;\n }\n\n if (!babelResult.success) {\n errors.push(babelResult.error);\n } else if (babelResult.module) {\n modules.babel = babelResult.module;\n }\n\n if (!reactResult.success) {\n errors.push(reactResult.error);\n } else if (reactResult.module) {\n modules.react = reactResult.module;\n }\n\n lineLog();\n\n if (errors.length > 0) {\n return { success: false, errors };\n }\n\n return { success: true, modules };\n}\n"],"names":[],"mappings":";;;;;AA8CgB,SAAA,cACd,aACA,SACA,SACsB;;AAChB,QAAA,iCAAiB,IAAa;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AACD,aAAW,KAAK,SAAS;AACvB,eAAW,OAAO,CAAC;AAAA,EAAA;AAGrB,MAAI,aAAmC;AAEvC,aAAW,UAAU,YAAY;AAC/B,UAAM,cAAa,iBAAY,MAAM,MAAlB,mBAAsB;AACzC,QAAI,YAAY;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YAAY;AAAA,EAAA;AAGtB,UAAA;AAEJ,MAAA,OAAO,SAAS,GAAG;AACd,WAAA,EAAE,SAAS,OAAO,OAAO;AAAA,EAAA;AAG3B,SAAA,EAAE,SAAS,MAAM,QAAQ;AAClC;"}
|
@@ -2,7 +2,7 @@ import { type Args } from "./args.js";
|
|
2
2
|
import { PrettyError } from "./PrettyErrors.js";
|
3
3
|
export declare function defineViteConfig(args?: Args): Promise<import("vite").UserConfig | {
|
4
4
|
error: boolean;
|
5
|
-
errors:
|
5
|
+
errors: any;
|
6
6
|
}>;
|
7
7
|
type RunResult = {
|
8
8
|
error: false;
|