From c79fb73bec4e5acefa96d5af0e9eda145731a87c Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Fri, 6 Feb 2026 23:55:30 -0800 Subject: [PATCH] Simplify dts bundles and clean up globby wrapper --- .vscode/launch.json | 14 +- ...undle-generator-npm-9.5.1-0927b6826f.patch | 232 ++++++++++++++++++ .../fast-glob-npm-3.3.3-2a653be532.patch | 104 ++++++++ ...-9115f1bd-4c91-4311-af52-c634603f5a27.json | 18 ++ lage.config.js | 1 + package.json | 11 +- packages/globby/README.md | 2 + packages/globby/dts-bundle.config.js | 30 +-- packages/globby/package.json | 34 ++- packages/globby/scripts/rename.js | 4 - packages/globby/src/index.mts | 2 +- packages/lage/dts-bundle.config.js | 76 +----- packages/lage/package.json | 21 +- packages/lage/scripts/bundle.mjs | 82 ++++--- packages/lage/scripts/prebuild.js | 26 -- .../scripts/retain-dynamic-import-plugin.js | 19 -- packages/lage/scripts/update-dts-bundle.js | 65 ----- packages/lage/tsconfig.json | 12 + scripts/config/getDtsBundleConfig.js | 125 ++++++++++ scripts/config/tsconfig.base.json | 1 + scripts/package.json | 4 +- scripts/tsconfig.json | 1 + scripts/worker/depcheck.js | 1 + scripts/worker/transpile.js | 15 +- scripts/worker/types.js | 5 +- yarn.lock | 78 ++++-- 26 files changed, 687 insertions(+), 296 deletions(-) create mode 100644 .yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch create mode 100644 .yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch create mode 100644 change/change-9115f1bd-4c91-4311-af52-c634603f5a27.json delete mode 100644 packages/globby/scripts/rename.js delete mode 100644 packages/lage/scripts/prebuild.js delete mode 100644 packages/lage/scripts/retain-dynamic-import-plugin.js delete mode 100644 packages/lage/scripts/update-dts-bundle.js create mode 100644 packages/lage/tsconfig.json create mode 100644 scripts/config/getDtsBundleConfig.js diff --git a/.vscode/launch.json b/.vscode/launch.json index ca5d822f2..0981b9ca1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -22,8 +22,7 @@ }, "runtimeArgs": [], "sourceMaps": true, - "cwd": "${workspaceRoot}", - "protocol": "inspector" + "cwd": "${workspaceRoot}" }, { "name": "Debug current open test", @@ -35,6 +34,17 @@ "sourceMaps": true, "outputCapture": "std", "console": "integratedTerminal" + }, + { + "name": "Debug dts-bundle-generator (lage)", + "request": "launch", + "type": "node", + "runtimeExecutable": "yarn", + "runtimeArgs": ["run", "bundle:dts"], + "cwd": "${workspaceFolder}/packages/lage", + "console": "integratedTerminal", + "outputCapture": "std", + "sourceMaps": true } ] } diff --git a/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch b/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch new file mode 100644 index 000000000..668c5ab7e --- /dev/null +++ b/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch @@ -0,0 +1,232 @@ +diff --git a/config-schema.d.ts b/config-schema.d.ts +index 38cb141223fe79fcc00c60c0cdc5e19490f9421a..3111af423e59f186a726200fad2302d615783a51 100644 +--- a/config-schema.d.ts ++++ b/config-schema.d.ts +@@ -48,23 +48,30 @@ export interface OutputOptions { + */ + exportReferencedTypes?: boolean; + } ++ ++// ++// This patch adds regexp support to certain options. ++// Once https://github.com/timocov/dts-bundle-generator/pull/355 is merged and published, ++// update to that version and remove this patch. ++// ++ + export interface LibrariesOptions { + /** + * Array of package names from node_modules to inline typings from. + * Used types will be inlined into the output file. + */ +- inlinedLibraries?: string[]; ++ inlinedLibraries?: (string | RegExp)[]; + /** + * Array of package names from node_modules to import typings from. + * Used types will be imported using `import { First, Second } from 'library-name';`. + * By default all libraries will be imported (except inlined libraries and libraries from @types). + */ +- importedLibraries?: string[]; ++ importedLibraries?: (string | RegExp)[]; + /** + * Array of package names from @types to import typings from via the triple-slash reference directive. + * By default all packages are allowed and will be used according to their usages. + */ +- allowedTypesLibraries?: string[]; ++ allowedTypesLibraries?: (string | RegExp)[]; + } + export interface EntryPointConfig { + /** +diff --git a/dist/bundle-generator.d.ts b/dist/bundle-generator.d.ts +index 3575bc66b7a0739e944d2bfa136867f76010c7df..d9d8c56f0fecfebb24ee35c1773adc1447e29bd2 100644 +--- a/dist/bundle-generator.d.ts ++++ b/dist/bundle-generator.d.ts +@@ -53,18 +53,18 @@ export interface LibrariesOptions { + * Array of package names from node_modules to inline typings from. + * Used types will be inlined into the output file. + */ +- inlinedLibraries?: string[]; ++ inlinedLibraries?: (string | RegExp)[]; + /** + * Array of package names from node_modules to import typings from. + * Used types will be imported using `import { First, Second } from 'library-name';`. + * By default all libraries will be imported (except inlined libraries and libraries from @types). + */ +- importedLibraries?: string[]; ++ importedLibraries?: (string | RegExp)[]; + /** + * Array of package names from @types to import typings from via the triple-slash reference directive. + * By default all packages are allowed and will be used according to their usages. + */ +- allowedTypesLibraries?: string[]; ++ allowedTypesLibraries?: (string | RegExp)[]; + } + export interface EntryPointConfig { + /** +diff --git a/dist/compile-dts.js b/dist/compile-dts.js +index 0585517f56446c9c51990dec6bf451f92458dea9..c171c8bb83a8b86ada4f3d6768d5911329f7b698 100644 +--- a/dist/compile-dts.js ++++ b/dist/compile-dts.js +@@ -100,7 +100,8 @@ function createCachingCompilerHost(compilerOptions) { + function changeExtensionToDts(fileName) { + let ext; + // `path.extname` doesn't handle `.d.ts` cases (it returns `.ts` instead of `.d.ts`) +- if (fileName.endsWith(ts.Extension.Dts)) { ++ // FIX: .d.mts cases ++ if (fileName.endsWith(ts.Extension.Dts) || fileName.endsWith(ts.Extension.Dmts) || fileName.endsWith(ts.Extension.Dcts)) { + return fileName; + } + if (fileName.endsWith(ts.Extension.Cts)) { +diff --git a/dist/config-file/check-schema-match.js b/dist/config-file/check-schema-match.js +index b2c8b2a2ec12360476853e7b48e8ae70e8106a8f..046ae58d0c63e4cb82ea86adeb591fba55720bf7 100644 +--- a/dist/config-file/check-schema-match.js ++++ b/dist/config-file/check-schema-match.js +@@ -6,6 +6,7 @@ exports.schemaPrimitiveValues = { + requiredBoolean: true, + string: '', + requiredString: 'REQUIRED', ++ stringOrRegExp: 'StringOrRegExp', + }; + const schemaRequiredValues = new Set([ + exports.schemaPrimitiveValues.requiredBoolean, +@@ -21,43 +22,62 @@ function checkSchemaMatch(value, schema, errors) { + exports.checkSchemaMatch = checkSchemaMatch; + // eslint-disable-next-line complexity + function checkSchemaMatchRecursively(value, schema, prefix, errors) { +- if (typeof schema === 'boolean' || typeof schema === 'string') { +- const schemeType = typeof schema; +- if (value === undefined && schemaRequiredValues.has(schema)) { +- errors.push(`Value for "${prefix}" is required and must have type "${schemeType}"`); ++ if (value === undefined && schemaRequiredValues.has(schema)) { ++ errors.push(`Value for "${prefix}" is required and must have type "${typeof schema}"`); ++ return false; ++ } ++ if (value === undefined || value === null) { ++ return true; ++ } ++ if (schema === exports.schemaPrimitiveValues.stringOrRegExp) { ++ if (!(value instanceof RegExp) && typeof value !== 'string') { ++ errors.push(`Value for "${prefix}" must be a string or RegExp`); + return false; + } ++ return true; ++ } ++ if (typeof schema === 'boolean' || typeof schema === 'string') { ++ const schemeType = typeof schema; + const valueType = typeof value; +- if (value !== undefined && typeof schema !== valueType) { +- errors.push(`Type of values for "${prefix}" is not the same, expected=${schemeType}, actual=${valueType}`); ++ if (schemeType !== valueType) { ++ errors.push(`Incorrect value type for "${prefix}": expected=${schemeType}, actual=${valueType}`); + return false; + } + return true; + } +- if (value === undefined) { +- return true; +- } + if (Array.isArray(schema)) { + if (!Array.isArray(value)) { ++ errors.push(`Value for "${prefix}" must be an array`); + return false; + } + let result = true; + for (let i = 0; i < value.length; ++i) { +- if (!checkSchemaMatchRecursively(value[i], schema[0], `${prefix}[${i}]`, errors)) { ++ if (value[i] === undefined || value[i] === null) { ++ // undefined is not valid within arrays ++ errors.push(`Value for "${prefix}[${i}]" is ${value[i]}`); ++ result = false; ++ } ++ else if (!checkSchemaMatchRecursively(value[i], schema[0], `${prefix}[${i}]`, errors)) { + result = false; + } + } + return result; + } ++ if (typeof value !== 'object') { ++ errors.push(`Value for "${prefix}" must be an object`); ++ return false; ++ } ++ // At this point the schema and T are objects, but the compiler can't infer it ++ const schemaObject = schema; + let result = true; + for (const valueKey of Object.keys(value)) { +- if (schema[valueKey] === undefined) { +- errors.push(`Exceeded property "${valueKey}" found in ${prefix.length === 0 ? 'the root' : prefix}`); ++ if (schemaObject[valueKey] === undefined) { ++ errors.push(`Excess property "${valueKey}" found in ${prefix.length === 0 ? 'the root' : prefix}`); + result = false; + } + } +- for (const schemaKey of Object.keys(schema)) { +- const isSubValueSchemeMatched = checkSchemaMatchRecursively(value[schemaKey], schema[schemaKey], prefix.length === 0 ? schemaKey : `${prefix}.${schemaKey}`, errors); ++ for (const schemaKey of Object.keys(schemaObject)) { ++ const isSubValueSchemeMatched = checkSchemaMatchRecursively(value[schemaKey], schemaObject[schemaKey], prefix.length === 0 ? schemaKey : `${prefix}.${schemaKey}`, errors); + result = result && isSubValueSchemeMatched; + } + return result; +diff --git a/dist/config-file/load-config-file.js b/dist/config-file/load-config-file.js +index 44a30ef61469c85d6bcc87067240f8de3126d9cf..f53acf45f4e81bb08b1442c88e5eb2009f913645 100644 +--- a/dist/config-file/load-config-file.js ++++ b/dist/config-file/load-config-file.js +@@ -44,9 +44,9 @@ const configScheme = { + failOnClass: check_schema_match_1.schemaPrimitiveValues.boolean, + noCheck: check_schema_match_1.schemaPrimitiveValues.boolean, + libraries: { +- allowedTypesLibraries: [check_schema_match_1.schemaPrimitiveValues.string], +- importedLibraries: [check_schema_match_1.schemaPrimitiveValues.string], +- inlinedLibraries: [check_schema_match_1.schemaPrimitiveValues.string], ++ allowedTypesLibraries: [check_schema_match_1.schemaPrimitiveValues.stringOrRegExp], ++ importedLibraries: [check_schema_match_1.schemaPrimitiveValues.stringOrRegExp], ++ inlinedLibraries: [check_schema_match_1.schemaPrimitiveValues.stringOrRegExp], + }, + output: { + inlineDeclareGlobals: check_schema_match_1.schemaPrimitiveValues.boolean, +diff --git a/dist/helpers/typescript.js b/dist/helpers/typescript.js +index b61f02fb2545238718631ce4791ac71910f4d0eb..efb8d1a33493032c79b589c35226353a8a9e58a9 100644 +--- a/dist/helpers/typescript.js ++++ b/dist/helpers/typescript.js +@@ -254,7 +254,7 @@ function modifiersToMap(modifiers) { + return modifiers.reduce((result, modifier) => { + result[modifier.kind] = true; + return result; +- }, ++ }, + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions + {}); + } +@@ -302,7 +302,7 @@ function recreateRootLevelNodeWithModifiersImpl(node, modifiersMap, newName) { + return ts.factory.createExportAssignment(modifiers, node.isExportEquals, node.expression); + } + if (ts.isExportDeclaration(node)) { +- return ts.factory.createExportDeclaration(modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, ++ return ts.factory.createExportDeclaration(modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier, + // eslint-disable-next-line deprecation/deprecation + node.attributes || node.assertClause); + } +@@ -313,7 +313,7 @@ function recreateRootLevelNodeWithModifiersImpl(node, modifiersMap, newName) { + return ts.factory.createFunctionExpression(modifiers, node.asteriskToken, newName || node.name, node.typeParameters, node.parameters, node.type, node.body); + } + if (ts.isImportDeclaration(node)) { +- return ts.factory.createImportDeclaration(modifiers, node.importClause, node.moduleSpecifier, ++ return ts.factory.createImportDeclaration(modifiers, node.importClause, node.moduleSpecifier, + // eslint-disable-next-line deprecation/deprecation + node.attributes || node.assertClause); + } +diff --git a/dist/module-info.js b/dist/module-info.js +index acbd74b2e71563ebe324a538156a9a18122f4314..3f4d96999187d2c8e84960f43d739591e1343fc8 100644 +--- a/dist/module-info.js ++++ b/dist/module-info.js +@@ -79,8 +79,10 @@ function shouldLibraryBeImported(npmLibraryName, typesLibraryName, importedLibra + } + return false; + } +-function isLibraryAllowed(libraryName, allowedArray) { +- return allowedArray === undefined || allowedArray.indexOf(libraryName) !== -1; ++function isLibraryAllowed(libraryName, allowed) { ++ return Array.isArray(allowed) ++ ? allowed.some(item => typeof item === 'string' ? item === libraryName : item.test(libraryName)) ++ : true; + } + function remapToTypesFromNodeModules(pathRelativeToTypesRoot) { + return `node_modules/@types/${pathRelativeToTypesRoot}`; diff --git a/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch b/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch new file mode 100644 index 000000000..3d8325b61 --- /dev/null +++ b/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch @@ -0,0 +1,104 @@ +diff --git a/out/index.d.ts b/out/index.d.ts +index 46823bb5ffe389587d33ad937c80240d025c8033..602f4b3f66598d4cc771f5660de72a9d6ced2098 100644 +--- a/out/index.d.ts ++++ b/out/index.d.ts +@@ -1,40 +1,13 @@ +-/// +-import * as taskManager from './managers/tasks'; +-import { Options as OptionsInternal } from './settings'; +-import { Entry as EntryInternal, FileSystemAdapter as FileSystemAdapterInternal, Pattern as PatternInternal } from './types'; +-type EntryObjectModePredicate = { +- [TKey in keyof Pick]-?: true; +-}; +-type EntryStatsPredicate = { +- [TKey in keyof Pick]-?: true; +-}; +-type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate; +-declare function FastGlob(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): Promise; +-declare function FastGlob(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Promise; ++// ++// This patch works around issues with dts-bundle-generator incorrectly handling renamed types ++// in certain cases, especially with namespace exports. ++// ++import { OptionsInternal } from './settings'; ++import { EntryInternal } from './types'; + declare namespace FastGlob { + type Options = OptionsInternal; ++ // workaround for dts-bundle-generator bug with namespace exports ++ type FastGlobOptions = OptionsInternal; + type Entry = EntryInternal; +- type Task = taskManager.Task; +- type Pattern = PatternInternal; +- type FileSystemAdapter = FileSystemAdapterInternal; +- const glob: typeof FastGlob; +- const globSync: typeof sync; +- const globStream: typeof stream; +- const async: typeof FastGlob; +- function sync(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): EntryInternal[]; +- function sync(source: PatternInternal | PatternInternal[], options?: OptionsInternal): string[]; +- function stream(source: PatternInternal | PatternInternal[], options?: OptionsInternal): NodeJS.ReadableStream; +- function generateTasks(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Task[]; +- function isDynamicPattern(source: PatternInternal, options?: OptionsInternal): boolean; +- function escapePath(source: string): PatternInternal; +- function convertPathToPattern(source: string): PatternInternal; +- namespace posix { +- function escapePath(source: string): PatternInternal; +- function convertPathToPattern(source: string): PatternInternal; +- } +- namespace win32 { +- function escapePath(source: string): PatternInternal; +- function convertPathToPattern(source: string): PatternInternal; +- } + } + export = FastGlob; +diff --git a/out/settings.d.ts b/out/settings.d.ts +index 76a74f8a7b45fc79a00db925fd9cfdbbe1be1324..09dc7576987d059d835e7b500e4935e110d0e7a1 100644 +--- a/out/settings.d.ts ++++ b/out/settings.d.ts +@@ -1,6 +1,6 @@ + import { FileSystemAdapter, Pattern } from './types'; + export declare const DEFAULT_FILE_SYSTEM_ADAPTER: FileSystemAdapter; +-export type Options = { ++export type OptionsInternal = { + /** + * Return the absolute path for entries. + * +@@ -158,7 +158,7 @@ export default class Settings { + readonly suppressErrors: boolean; + readonly throwErrorOnBrokenSymbolicLink: boolean; + readonly unique: boolean; +- constructor(_options?: Options); ++ constructor(_options?: OptionsInternal); + private _getValue; + private _getFileSystemMethods; + } +diff --git a/out/types/index.d.ts b/out/types/index.d.ts +index 6506cafd19c16068aae470e5ae4bf4813d7ede97..8f5f90640ecba0ebed09922e685edb0b43cf5877 100644 +--- a/out/types/index.d.ts ++++ b/out/types/index.d.ts +@@ -1,13 +1,13 @@ + /// + import * as fsWalk from '@nodelib/fs.walk'; + export type ErrnoException = NodeJS.ErrnoException; +-export type Entry = fsWalk.Entry; +-export type EntryItem = string | Entry; ++export type EntryInternal = fsWalk.Entry; ++export type EntryItem = string | EntryInternal; + export type Pattern = string; + export type PatternRe = RegExp; + export type PatternsGroup = Record; + export type ReaderOptions = fsWalk.Options & { +- transform(entry: Entry): EntryItem; ++ transform(entry: EntryInternal): EntryItem; + deepFilter: DeepFilterFunction; + entryFilter: EntryFilterFunction; + errorFilter: ErrorFilterFunction; +@@ -17,7 +17,7 @@ export type ReaderOptions = fsWalk.Options & { + export type ErrorFilterFunction = fsWalk.ErrorFilterFunction; + export type EntryFilterFunction = fsWalk.EntryFilterFunction; + export type DeepFilterFunction = fsWalk.DeepFilterFunction; +-export type EntryTransformerFunction = (entry: Entry) => EntryItem; ++export type EntryTransformerFunction = (entry: EntryInternal) => EntryItem; + export type MicromatchOptions = { + dot?: boolean; + matchBase?: boolean; diff --git a/change/change-9115f1bd-4c91-4311-af52-c634603f5a27.json b/change/change-9115f1bd-4c91-4311-af52-c634603f5a27.json new file mode 100644 index 000000000..a2a7190f0 --- /dev/null +++ b/change/change-9115f1bd-4c91-4311-af52-c634603f5a27.json @@ -0,0 +1,18 @@ +{ + "changes": [ + { + "type": "patch", + "comment": "Switch to version 13 to match Node 14. Fix the bundled types and add a readme.", + "packageName": "@lage-run/globby", + "email": "elcraig@microsoft.com", + "dependentChangeType": "patch" + }, + { + "type": "patch", + "comment": "Simplify the types bundle setup", + "packageName": "lage", + "email": "elcraig@microsoft.com", + "dependentChangeType": "patch" + } + ] +} \ No newline at end of file diff --git a/lage.config.js b/lage.config.js index 220713d07..07d7a6821 100644 --- a/lage.config.js +++ b/lage.config.js @@ -10,6 +10,7 @@ const fastGlob = require("fast-glob"); const config = { pipeline: { "lage#bundle": ["^^transpile", "types"], + // Note that transpile/types/bundle are overridden later for the @lage-run/globby package types: { type: "worker", options: { diff --git a/package.json b/package.json index 8079a570c..0beb246ef 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "ci": "lage transpile types build test lint bundle", "release": "beachball publish -y --tag latest", "test": "lage test --verbose", + "lage-local": "node packages/lage/dist/lage.js", "lint": "lage lint", "deps:check": "lage depcheck", "decks:build": "npm exec --package=@marp-team/marp-cli -- marp -I decks --pdf -o decks/dist", @@ -37,6 +38,7 @@ "@types/jest": "^30.0.0", "@types/node": "^16.18.3", "beachball": "^2.63.0", + "dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch", "fast-glob": "3.3.3", "husky": "^9.1.5", "jest": "^30.0.0", @@ -52,16 +54,21 @@ "@types/node@npm:*": "^16.0.0", "typescript@npm:>=5.0.2": "~5.9.3", "node-gyp@npm:latest": "^11.0.0", - "listr2@npm:^9.0.5": "9.0.3" + "listr2@npm:^9.0.5": "9.0.3", + "globby/fast-glob": "patch:fast-glob@npm%3A3.3.3#~/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch" }, "rationale": { "resolutions": { "node-gyp@npm:latest": "Stop pulling in other newer deps", - "listr2@npm:^9.0.5": "Prevent pulling in cli-truncate@5 => string-width@8 which requires Node 20" + "listr2@npm:^9.0.5": "Prevent pulling in cli-truncate@5 => string-width@8 which requires Node 20", + "globby/fast-glob": "Fix name collision in @lage-run/globby dts-bundle-generator'd types" } }, "lint-staged": { "*": "prettier --write" }, + "engines": { + "node": ">=14.13.1" + }, "packageManager": "yarn@4.12.0" } diff --git a/packages/globby/README.md b/packages/globby/README.md index e2c7beb25..a0c5cbaa1 100644 --- a/packages/globby/README.md +++ b/packages/globby/README.md @@ -1 +1,3 @@ CommonJS wrapper of [`globby`](https://www.npmjs.com/package/globby) with caching support and all dependencies bundled. + +This should follow the newest version of `globby` compatible with Lage's minimum Node version. As of writing, that's Node 14 and `globby` 13. diff --git a/packages/globby/dts-bundle.config.js b/packages/globby/dts-bundle.config.js index 9ff223376..8e28a5958 100644 --- a/packages/globby/dts-bundle.config.js +++ b/packages/globby/dts-bundle.config.js @@ -1,26 +1,8 @@ // @ts-check -const path = require("path"); +const getDtsBundleConfig = require("@lage-run/monorepo-scripts/config/getDtsBundleConfig"); -/** @type {import('dts-bundle-generator/config-schema').BundlerConfig} */ -const config = { - compilationOptions: { - preferredConfigPath: require.resolve("@lage-run/monorepo-scripts/config/tsconfig.dts-bundle.json"), - }, - entries: [ - { - filePath: path.join(__dirname, "lib/index.d.ts"), - outFile: "./dist/index.d.ts", - libraries: { - // Inline any types from workspace packages into the dts bundle - inlinedLibraries: ["globby"], - }, - output: { - // Only export the types which are explicitly exported in the original files - // (rather than all types referenced by exported types) - exportReferencedTypes: true, - noBanner: true, - }, - }, - ], -}; -module.exports = config; +module.exports = getDtsBundleConfig({ + entryFile: "./lib/index.d.mts", + outFile: "./dist/index.d.ts", + inlinedLibraries: ["fast-glob", "globby", /^@nodelib\//], +}); diff --git a/packages/globby/package.json b/packages/globby/package.json index 8481eecc9..4b63ac8d4 100644 --- a/packages/globby/package.json +++ b/packages/globby/package.json @@ -1,30 +1,28 @@ { "name": "@lage-run/globby", - "version": "14.2.2", - "main": "lib/index.js", + "version": "13.0.0", + "license": "MIT", + "description": "Bundled CJS wrapper of globby with caching support", + "main": "dist/index.js", + "exports": { + ".": { + "source": "./src/index.mts", + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + } + }, "scripts": { "build": "yarn types && yarn transpile", - "transpile": "esbuild src/index.mts --bundle --platform=node --target=node14 --format=cjs --outfile=lib/index.js", - "types": "yarn tsc && node scripts/rename.js && yarn dts-bundle-generator --config ./dts-bundle.config.js" + "transpile": "esbuild src/index.mts --bundle --platform=node --target=node14 --format=cjs --outfile=dist/index.js --tree-shaking", + "types": "yarn run -T tsc && yarn bundle:dts", + "bundle:dts": "yarn run -T dts-bundle-generator --config ./dts-bundle.config.js" }, - "license": "MIT", "devDependencies": { "@lage-run/monorepo-scripts": "workspace:^", - "dts-bundle-generator": "^9.5.1", "esbuild": "^0.25.0", - "globby": "^14.0.2", - "typescript": "~5.9.3" - }, - "exports": { - ".": { - "types": "./dist/index.d.ts", - "import": "./lib/index.js", - "require": "./lib/index.js", - "source": "./src/index.mts" - } + "globby": "^13.0.0" }, "files": [ - "lib/!(__*)", - "lib/!(__*)/**" + "dist" ] } diff --git a/packages/globby/scripts/rename.js b/packages/globby/scripts/rename.js deleted file mode 100644 index c1606aff2..000000000 --- a/packages/globby/scripts/rename.js +++ /dev/null @@ -1,4 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -fs.renameSync(path.join(__dirname, "../lib/index.d.mts"), path.join(__dirname, "../lib/index.d.ts")); diff --git a/packages/globby/src/index.mts b/packages/globby/src/index.mts index 571349eea..e3b18f18c 100644 --- a/packages/globby/src/index.mts +++ b/packages/globby/src/index.mts @@ -22,4 +22,4 @@ export function glob(patterns: string[], options?: Options): string[] { return cache.get(key) || []; } -export { type Options }; +export type { Options }; diff --git a/packages/lage/dts-bundle.config.js b/packages/lage/dts-bundle.config.js index e577de0d5..473f1bd80 100644 --- a/packages/lage/dts-bundle.config.js +++ b/packages/lage/dts-bundle.config.js @@ -4,73 +4,17 @@ // Since `lage`'s config types are defined in `@lage-run/cli` (and its dependencies), and `lage` ships // a bundle rather than installing dependencies, it's also necessary to bundle the types in case // consumers want to use them in their own lage configs. -// -// Ideally we would only have a single dts bundle, but there are a couple problems: -// - `lage` types extend from `backfill-config` types, and there are some naming conflicts. -// - `lage` types sometimes reference or re-export `backfill-config` types under different names, -// which isn't handled well by `dts-bundle-generator`. -// -// As a workaround, the `backfill-config` types are bundled in a separate file, and the imports -// in bundled `lage` types will be rewritten later (by scripts/update-dts-bundle.js) to point to -// the local `backfill-config` bundle file rather than the npm package. -// -// The update script also does some basic validation: mainly detecting if a new dep is used which -// needs to be added to one of the `inlinedLibraries` lists below. // @ts-check -const path = require("path"); -const { getPackageInfos } = require("workspace-tools"); +const getDtsBundleConfig = require("@lage-run/monorepo-scripts/config/getDtsBundleConfig"); -/** @type {import('dts-bundle-generator/config-schema').OutputOptions} */ -const commonOutputOptions = { - // Only export the types which are explicitly exported in the original files - // (rather than all types referenced by exported types) - exportReferencedTypes: false, - noBanner: true, -}; - -/** @type {import('dts-bundle-generator/config-schema').BundlerConfig} */ -const config = { - compilationOptions: { - preferredConfigPath: require.resolve("@lage-run/monorepo-scripts/config/tsconfig.dts-bundle.json"), - }, - entries: [ - { - filePath: path.join(path.dirname(require.resolve("@lage-run/cli/package.json")), "lib/index.d.ts"), - outFile: "./dist/index.d.ts", - libraries: { - // Inline any types from workspace packages into the dts bundle - inlinedLibraries: Object.values(getPackageInfos(process.cwd())) - .filter((p) => p.name !== "lage" && !p.private) - .map((p) => p.name), - }, - output: commonOutputOptions, - }, - // See file comment for explanation of why this a second bundle is needed - { - filePath: path.join(path.dirname(require.resolve("backfill-config/package.json")), "lib/index.d.ts"), - outFile: "./dist/backfill-config.d.ts", - libraries: { - // Note that backfill-config itself must be in this list, or references to files within the - // package will be treated as external and preserved as imports. - inlinedLibraries: [ - "backfill-config", - "backfill-logger", - "@azure/abort-controller", - "@azure/core-auth", - "@azure/core-http", - "@azure/core-lro", - "@azure/core-paging", - "@azure/core-tracing", - "@azure/core-util", - "@azure/logger", - "@azure/storage-blob", - ], - }, - output: commonOutputOptions, - noCheck: true, - }, +module.exports = getDtsBundleConfig({ + entryFile: "../cli/lib/index.d.ts", + outFile: "./dist/index.d.ts", + inlinedLibraries: [ + // Inline any types from lage packages into the dts bundle + /^@lage-run\//, + // Also expected dependencies + /^backfill-/, ], -}; - -module.exports = config; +}); diff --git a/packages/lage/package.json b/packages/lage/package.json index c6ec8f015..e386403cb 100644 --- a/packages/lage/package.json +++ b/packages/lage/package.json @@ -13,8 +13,11 @@ "lage-server": "dist/lage-server.js" }, "scripts": { - "bundle": "node scripts/prebuild.js && yarn dts-bundle && node scripts/bundle.mjs", - "dts-bundle": "dts-bundle-generator --config ./dts-bundle.config.js && node ./scripts/update-dts-bundle.js" + "build": "yarn types", + "types": "yarn run -T tsc", + "bundle": "yarn bundle:js && yarn bundle:dts", + "bundle:js": "node scripts/bundle.mjs", + "bundle:dts": "yarn run -T dts-bundle-generator --config ./dts-bundle.config.js" }, "dependencies": { "glob-hasher": "^1.4.2" @@ -26,19 +29,9 @@ "@lage-run/cli": "workspace:^", "@lage-run/monorepo-scripts": "workspace:^", "@lage-run/runners": "workspace:^", - "backfill-config": "6.7.1", - "dts-bundle-generator": "^9.5.1", - "esbuild": "^0.25.0", - "esbuild-plugin-alias": "^0.2.1", - "workspace-tools": "0.41.0" + "esbuild": "^0.25.0" }, "files": [ - "dist/*.d.ts", - "dist/lage.js", - "dist/lage.js.map", - "dist/runners/*", - "dist/workers/*", - "dist/singleTargetWorker.js", - "dist/singleTargetWorker.js.map" + "dist" ] } diff --git a/packages/lage/scripts/bundle.mjs b/packages/lage/scripts/bundle.mjs index 1bff7d537..2f86a1e08 100644 --- a/packages/lage/scripts/bundle.mjs +++ b/packages/lage/scripts/bundle.mjs @@ -1,32 +1,58 @@ +// @ts-check import * as esbuild from "esbuild"; -import alias from "esbuild-plugin-alias"; +import fs from "fs"; +import path from "path"; +import { fileURLToPath } from "url"; -async function bundle(entry, outfile, addBanner = false) { - await esbuild.build({ - entryPoints: [entry], - bundle: true, - platform: "node", - target: ["node16"], - outfile, - sourcemap: true, - external: [ - "fsevents", - "glob-hasher", - "./runners/NpmScriptsRunner.js", - "./runners/NoOpRunner.js", - "./runners/WorkerRunner.js", - "./workers/targetWorker", - "./singleTargetWorker.js", - ], - ...(addBanner && { banner: { js: "#!/usr/bin/env node" } }), - minify: true, - }); +const dirname = path.dirname(fileURLToPath(import.meta.url)); +const packageRoot = path.resolve(dirname, ".."); +const runnerDirs = [path.resolve(packageRoot, "../runners/lib"), path.resolve(packageRoot, "../cli/lib/commands/cache/runners")]; + +console.log("Bundling with esbuild..."); + +// Due to the fact that workers require the runner to be in the same directory, we need to copy the runners to the dist folder +for (const runnerDir of runnerDirs) { + for (const runner of fs.readdirSync(runnerDir)) { + // By convention, only copy things that end with "Runner.js" + if (runner.endsWith("Runner.js")) { + const src = path.join(runnerDir, runner); + const dest = path.join(packageRoot, "dist/runners", runner); + fs.mkdirSync(path.dirname(dest), { recursive: true }); + fs.copyFileSync(src, dest); + } + } +} + +await esbuild.build({ + entryPoints: { + lage: "@lage-run/cli/lib/cli.js", + "lage-server": "@lage-run/cli/lib/server.js", + main: "./index.js", + "workers/targetWorker": "@lage-run/scheduler/lib/workers/targetWorker.js", + singleTargetWorker: "@lage-run/cli/lib/commands/server/singleTargetWorker.js", + }, + outdir: "dist", + bundle: true, + platform: "node", + target: ["node14"], + sourcemap: true, + external: [ + "fsevents", + "glob-hasher", + "./runners/NpmScriptRunner.js", + "./runners/NoOpRunner.js", + "./runners/WorkerRunner.js", + "./workers/targetWorker", + "./singleTargetWorker.js", + ], + minify: true, +}); + +// Add a shebang to the executable files +for (const file of ["lage", "lage-server"]) { + const filePath = path.join(packageRoot, "dist", file + ".js"); + const content = fs.readFileSync(filePath, "utf8"); + fs.writeFileSync(filePath, "#!/usr/bin/env node\n" + content); } -await Promise.all([ - bundle("@lage-run/cli/lib/cli.js", "dist/lage.js", true), - bundle("@lage-run/cli/lib/server.js", "dist/lage-server.js", true), - bundle("./index.js", "dist/main.js"), - bundle("@lage-run/scheduler/lib/workers/targetWorker.js", "dist/workers/targetWorker.js"), - bundle("@lage-run/cli/lib/commands/server/singleTargetWorker.js", "dist/singleTargetWorker.js"), -]); +console.log("Bundling succeeded\n"); diff --git a/packages/lage/scripts/prebuild.js b/packages/lage/scripts/prebuild.js deleted file mode 100644 index 1aec0a4ac..000000000 --- a/packages/lage/scripts/prebuild.js +++ /dev/null @@ -1,26 +0,0 @@ -const fs = require("fs"); -const path = require("path"); - -const cwd = process.cwd(); -const runnersPath = path.dirname(require.resolve("@lage-run/runners/package.json")); -const cliPath = path.dirname(require.resolve("@lage-run/cli/package.json")); - -const runnerDirs = [path.join(runnersPath, "lib"), path.join(cliPath, "lib", "commands", "cache", "runners")]; - -function prebuild() { - // Due to the fact that workers require the runner to be in the same directory, we need to copy the runners to the dist folder - - for (const runnerDir of runnerDirs) { - for (const runner of fs.readdirSync(runnerDir)) { - // By convention, only copy things that end with "Runner.js" - if (runner.endsWith("Runner.js")) { - const src = path.join(runnerDir, runner); - const dest = path.join(cwd, "dist", "runners", runner); - fs.mkdirSync(path.dirname(dest), { recursive: true }); - fs.copyFileSync(src, dest); - } - } - } -} - -prebuild(); diff --git a/packages/lage/scripts/retain-dynamic-import-plugin.js b/packages/lage/scripts/retain-dynamic-import-plugin.js deleted file mode 100644 index 13dd0ef78..000000000 --- a/packages/lage/scripts/retain-dynamic-import-plugin.js +++ /dev/null @@ -1,19 +0,0 @@ -export function retainDynamicImport() { - return { - name: "retain-dynamic-import", - resolveDynamicImport(specifier) { - if (typeof specifier === "string") { - return null; - } - return false; - }, - renderDynamicImport(entry) { - if (!entry.targetModuleId) { - return { - left: "import(", - right: ")", - }; - } - }, - }; -} diff --git a/packages/lage/scripts/update-dts-bundle.js b/packages/lage/scripts/update-dts-bundle.js deleted file mode 100644 index f064069c0..000000000 --- a/packages/lage/scripts/update-dts-bundle.js +++ /dev/null @@ -1,65 +0,0 @@ -// -// See the comment in ../dts-bundle.config.js for why this is needed. -// - -// @ts-check -const fs = require("fs"); -const { builtinModules } = require("module"); -const path = require("path"); -const { findGitRoot } = require("workspace-tools"); - -const gitRoot = findGitRoot(process.cwd()); -const relativeFilename = path.relative(gitRoot, __filename); - -/** @type {Record} */ -const bundles = { - lage: { - path: path.resolve(__dirname, "../dist/index.d.ts"), - // These packages are bundled in sibling dts files, so imports should be rewritten to point there - rewriteImports: ["backfill-config"], - }, - "backfill-config": { - path: path.resolve(__dirname, "../dist/backfill-config.d.ts"), - }, -}; - -let hasError = false; - -// Scan through the imports to validate they're only referencing builtins or other bundled packages, -// and rewrite any package imports to point to the local bundle file -for (const [name, { path: bundlePath, rewriteImports }] of Object.entries(bundles)) { - const content = fs.readFileSync(bundlePath, "utf8"); - let newContent = content; - let unexpectedImports = /** @type {string[]} */ ([]); - - for (const [fullMatch, importName] of content.matchAll(/from ['"](.*?)['"]/g)) { - if (rewriteImports?.includes(importName)) { - newContent = newContent.replace(fullMatch, `from './${importName}.js'`); - } else if (!builtinModules.includes(importName)) { - unexpectedImports.push(importName); - } - } - - if (unexpectedImports.length) { - hasError = true; - console.error(` -Found unexpected new import(s) in the bundled types for "${name}": -${unexpectedImports.map((i) => ` ${i}`).join("\n")} -You may need to add the package(s) to the "inlinedLibraries" list for "${name}" in dts-bundle.config.js. -`); - } - - newContent = ` -// Bundle of types from "${name}" and packages it references. -// This file was generated by dts-bundle-generator and ${relativeFilename} - -${newContent}`; - { - fs.writeFileSync(bundlePath, newContent); - console.log(`Updated imports in "${name}" dts bundle at ${bundlePath}`); - } -} - -if (hasError) { - process.exit(1); -} diff --git a/packages/lage/tsconfig.json b/packages/lage/tsconfig.json new file mode 100644 index 000000000..c4b5297f6 --- /dev/null +++ b/packages/lage/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@lage-run/monorepo-scripts/config/tsconfig.base.json", + // Type check the scripts (the options are suitable for that). + // There's no meaningful source code since this is a bundle of a CLI tool. + "compilerOptions": { + "emitDeclarationOnly": false, + "noEmit": true, + "module": "Node16", + "moduleResolution": "Node16" + }, + "include": ["scripts", "dts-bundle.config.js"] +} diff --git a/scripts/config/getDtsBundleConfig.js b/scripts/config/getDtsBundleConfig.js new file mode 100644 index 000000000..0b6254171 --- /dev/null +++ b/scripts/config/getDtsBundleConfig.js @@ -0,0 +1,125 @@ +// @ts-check +/** @import { BundlerConfig } from "dts-bundle-generator/config-schema" */ +/** @import { TSESTree } from "@typescript-eslint/types" */ +const fs = require("fs"); +const { isBuiltin } = require("module"); +const path = require("path"); +const { getPackageInfo } = require("workspace-tools"); +const { parse } = require("@typescript-eslint/parser"); + +/** + * Get a config for `dts-bundle-generator`, which is basically like Rollup but for types. + * https://github.com/timocov/dts-bundle-generator/blob/master/src/config-file/README.md + * + * Also add a `beforeExit` listener to validate that there are no unexpected imports in the dts bundle. + * (Currently, all imports except Node builtins are considered unexpected. If a package later needs + * to externalize more libraries, more options can be added to this function.) + * + * @param {object} params + * @param {string} params.entryFile Path to the entry d.ts file (absolute or relative to package root) + * @param {string} params.outFile Path to the output bundled d.ts file (absolute or relative to package root) + * @param {(string | RegExp)[]} params.inlinedLibraries Inline types for these libraries + * @returns {BundlerConfig} + */ +function getDtsBundleConfig(params) { + console.log("Generating types bundle..."); + + const packageInfo = getPackageInfo(process.cwd()); + if (!packageInfo) { + throw new Error(`Could not find package root from ${process.cwd()}`); + } + const packageRoot = path.dirname(packageInfo.packageJsonPath); + + const entryFile = path.resolve(packageRoot, params.entryFile); + const outFile = path.resolve(packageRoot, params.outFile); + + // Use "once" because otherwise it will run again after the first run completes + process.once("beforeExit", async (code) => { + if (!code) { + console.log("Verifying no unexpected imports in bundled types"); + await onBeforeExit({ packageName: packageInfo.name, outFile }); + } + }); + + return { + compilationOptions: { + preferredConfigPath: path.join(__dirname, "./tsconfig.dts-bundle.json"), + }, + entries: [ + { + filePath: entryFile, + outFile, + libraries: { + inlinedLibraries: params.inlinedLibraries, + }, + output: { + // Only export the types which are explicitly exported in the original files + // (rather than all types referenced by exported types) + exportReferencedTypes: false, + noBanner: true, + inlineDeclareGlobals: true, + }, + }, + ], + }; +} + +/** + * Verify no unexpected imports were introduced in the bundled d.ts file. + * @param {object} params + * @param {string} params.packageName Package name being validated + * @param {string} params.outFile Absolute path to the bundled file + */ +async function onBeforeExit(params) { + const { packageName, outFile } = params; + + const content = fs.readFileSync(outFile, "utf8"); + + // Parse with typescript-eslint since it's already installed + const parsed = parse(content, { warnOnUnsupportedTypeScriptVersion: false }); + + const { walk } = await import("zimmerframe"); + + // Scan through the imports to validate they're only referencing builtins. + // (realistically it would probably be fine to just scan for top-level imports) + const /** @type {string[]} */ imports = []; + walk(/** @type {TSESTree.Node} */ (parsed), null, { + ImportDeclaration(node) { + imports.push(node.source.value); + }, + // import('foo') + ImportExpression(node) { + node.source.type === "Literal" && typeof node.source.value === "string" && imports.push(node.source.value); + }, + // typeof import('foo') + TSImportType(node) { + node.parameter.type === "TSLiteralType" && + node.parameter.literal.type === "Literal" && + typeof node.parameter.literal.value === "string" && + imports.push(node.parameter.literal.value); + }, + ExportNamedDeclaration(node) { + node.source && imports.push(node.source.value); + }, + ExportAllDeclaration(node) { + node.source && imports.push(node.source.value); + }, + // import foo = require('foo') + TSExternalModuleReference(node) { + node.expression.type === "Literal" && typeof node.expression.value === "string" && imports.push(node.expression.value); + }, + }); + + const unexpectedImports = imports.filter((i) => !isBuiltin(i)); + + if (unexpectedImports.length) { + console.error(` +Found unexpected new import(s) in the bundled types for ${packageName}: +${unexpectedImports.map((i) => ` ${i}`).join("\n")} +You may need to add the package(s) to the "inlinedLibraries" list in dts-bundle.config.js. +`); + process.exit(1); + } +} + +module.exports = getDtsBundleConfig; diff --git a/scripts/config/tsconfig.base.json b/scripts/config/tsconfig.base.json index 06954a57f..12a448563 100644 --- a/scripts/config/tsconfig.base.json +++ b/scripts/config/tsconfig.base.json @@ -4,6 +4,7 @@ "module": "CommonJS", "moduleResolution": "Node", "declaration": true, + "emitDeclarationOnly": true, "isolatedModules": true, "lib": ["ES2020"], "allowJs": true, diff --git a/scripts/package.json b/scripts/package.json index 3a28ee95a..845e32d5c 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -16,11 +16,13 @@ "@types/node": "^16.18.3", "@typescript-eslint/eslint-plugin": "^5.30.7", "@typescript-eslint/parser": "^5.30.7", + "@typescript-eslint/types": "^5.30.7", "depcheck": "^1.4.7", "eslint": "^8.20.0", "eslint-plugin-file-extension-in-import-ts": "^1.0.1", "jest": "^30.0.0", "typescript": "~5.9.3", - "workspace-tools": "0.41.0" + "workspace-tools": "0.41.0", + "zimmerframe": "^1.1.4" } } diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index d6200b8fc..3054d1c6e 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "./config/tsconfig.base.json", "compilerOptions": { + "emitDeclarationOnly": false, "noEmit": true, "paths": { // Special path mappings to avoid relative references in individual files diff --git a/scripts/worker/depcheck.js b/scripts/worker/depcheck.js index c2cb99f39..f40faca91 100644 --- a/scripts/worker/depcheck.js +++ b/scripts/worker/depcheck.js @@ -13,6 +13,7 @@ const extraIgnoreMatches = { "@lage-run/monorepo-scripts": ["@typescript-eslint/*", "eslint-plugin-file-extension-in-import-ts", "@types/*"], "@lage-run/rpc": ["@bufbuild/protoc-gen-es", "@connectrpc/protoc-gen-connect-es"], "@lage-run/e2e-tests": ["@lage-run/cli"], + lage: ["@lage-run/cli", "@lage-run/runners"], }; /** diff --git a/scripts/worker/transpile.js b/scripts/worker/transpile.js index 42309fbd3..208cbadb2 100644 --- a/scripts/worker/transpile.js +++ b/scripts/worker/transpile.js @@ -1,4 +1,5 @@ /** @import { Target } from "@/TargetGraph" */ +const fs = require("fs"); const path = require("path"); const fsPromises = require("fs/promises"); const swc = require("@swc/core"); @@ -16,7 +17,13 @@ async function transpile({ target }) { return; } - const queue = [target.cwd]; + // Start from the src directory to avoid unnecessary transpilation of scripts etc + const srcDir = path.join(target.cwd, "src"); + if (!fs.existsSync(srcDir)) { + return; + } + + const queue = [srcDir]; while (queue.length > 0) { const dir = /** @type {string} */ (queue.shift()); @@ -26,15 +33,15 @@ async function transpile({ target }) { for (let entry of entries) { const fullPath = path.join(dir, entry.name); - if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "lib" && entry.name !== "tests" && entry.name !== "dist") { + if (entry.isDirectory() && !entry.name.startsWith("__")) { queue.push(fullPath); - } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) { + } else if (entry.isFile() && entry.name.endsWith(".ts")) { + // ^ TOOD: this will be broken if there are .js files that need to go to lib, or .mts files (fix if needed in future) // Only replace src to 'lib' in the project tree. // The repo could be cloned in a folder with 'src' and we don't want to replace that with 'lib' const targetRelativePath = path .relative(target.cwd, fullPath) .replace("src" + path.sep, "lib" + path.sep) - .replace(".tsx", ".js") .replace(".ts", ".js"); const dest = path.join(target.cwd, targetRelativePath); const swcOutput = await swc.transformFile(fullPath, { diff --git a/scripts/worker/types.js b/scripts/worker/types.js index c0d3c00ae..ce4a261b3 100644 --- a/scripts/worker/types.js +++ b/scripts/worker/types.js @@ -16,7 +16,7 @@ const log = (/** @type {*} */ msg) => { * @param {{ target: Pick }} data */ async function run(data) { - const { target } = data; // Lage target data + const { target } = data; const tsconfigFile = "tsconfig.json"; const tsconfigJsonFile = path.join(target.cwd, tsconfigFile); @@ -50,9 +50,6 @@ async function run(data) { throw new Error("Could not parse tsconfig.json"); } - // for "types," we only generate declaration files - parsedCommandLine.options.emitDeclarationOnly = true; - const compilerOptions = parsedCommandLine.options; // Creating compilation host program diff --git a/yarn.lock b/yarn.lock index 9e46bf01d..cd8927f39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1655,10 +1655,8 @@ __metadata: resolution: "@lage-run/globby@workspace:packages/globby" dependencies: "@lage-run/monorepo-scripts": "workspace:^" - dts-bundle-generator: "npm:^9.5.1" esbuild: "npm:^0.25.0" - globby: "npm:^14.0.2" - typescript: "npm:~5.9.3" + globby: "npm:^13.0.0" languageName: unknown linkType: soft @@ -1688,6 +1686,7 @@ __metadata: "@types/jest": "npm:^30.0.0" "@types/node": "npm:^16.18.3" beachball: "npm:^2.63.0" + dts-bundle-generator: "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch" fast-glob: "npm:3.3.3" husky: "npm:^9.1.5" jest: "npm:^30.0.0" @@ -1729,12 +1728,14 @@ __metadata: "@types/node": "npm:^16.18.3" "@typescript-eslint/eslint-plugin": "npm:^5.30.7" "@typescript-eslint/parser": "npm:^5.30.7" + "@typescript-eslint/types": "npm:^5.30.7" depcheck: "npm:^1.4.7" eslint: "npm:^8.20.0" eslint-plugin-file-extension-in-import-ts: "npm:^1.0.1" jest: "npm:^30.0.0" typescript: "npm:~5.9.3" workspace-tools: "npm:0.41.0" + zimmerframe: "npm:^1.1.4" bin: monorepo-scripts: bin/monorepo-scripts.js languageName: unknown @@ -2420,7 +2421,7 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:5.62.0": +"@typescript-eslint/types@npm:5.62.0, @typescript-eslint/types@npm:^5.30.7": version: 5.62.0 resolution: "@typescript-eslint/types@npm:5.62.0" checksum: 10c0/7febd3a7f0701c0b927e094f02e82d8ee2cada2b186fcb938bc2b94ff6fbad88237afc304cbaf33e82797078bbbb1baf91475f6400912f8b64c89be79bfa4ddf @@ -3748,7 +3749,7 @@ __metadata: languageName: node linkType: hard -"dts-bundle-generator@npm:^9.5.1": +"dts-bundle-generator@npm:9.5.1": version: 9.5.1 resolution: "dts-bundle-generator@npm:9.5.1" dependencies: @@ -3760,6 +3761,18 @@ __metadata: languageName: node linkType: hard +"dts-bundle-generator@patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch": + version: 9.5.1 + resolution: "dts-bundle-generator@patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch::version=9.5.1&hash=187e0e" + dependencies: + typescript: "npm:>=5.0.2" + yargs: "npm:^17.6.0" + bin: + dts-bundle-generator: dist/bin/dts-bundle-generator.js + checksum: 10c0/860489167c6370cdd9d4fb895fbb887ddc11a2bf8be98dbcbc45fb7bf79138935a84194f3dc3ba2ee5f797b58cd6965c600a5ab9c8fd6763ff6c0a85e1f1680b + languageName: node + linkType: hard + "dunder-proto@npm:^1.0.1": version: 1.0.1 resolution: "dunder-proto@npm:1.0.1" @@ -3932,13 +3945,6 @@ __metadata: languageName: node linkType: hard -"esbuild-plugin-alias@npm:^0.2.1": - version: 0.2.1 - resolution: "esbuild-plugin-alias@npm:0.2.1" - checksum: 10c0/a67bc6bc2744fc8637f7321f00c1f00e4fae86c182662421738ebfabf3ad344967b9c667185c6c34d9edd5b289807d34bfdceef94620e94e0a45683534af69e0 - languageName: node - linkType: hard - "esbuild@npm:^0.25.0": version: 0.25.12 resolution: "esbuild@npm:0.25.12" @@ -4313,7 +4319,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:3.3.3, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.1, fast-glob@npm:^3.3.3": +"fast-glob@npm:3.3.3, fast-glob@npm:^3.3.1": version: 3.3.3 resolution: "fast-glob@npm:3.3.3" dependencies: @@ -4326,6 +4332,19 @@ __metadata: languageName: node linkType: hard +"fast-glob@patch:fast-glob@npm%3A3.3.3#~/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch": + version: 3.3.3 + resolution: "fast-glob@patch:fast-glob@npm%3A3.3.3#~/.yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch::version=3.3.3&hash=fce876" + dependencies: + "@nodelib/fs.stat": "npm:^2.0.2" + "@nodelib/fs.walk": "npm:^1.2.3" + glob-parent: "npm:^5.1.2" + merge2: "npm:^1.3.0" + micromatch: "npm:^4.0.8" + checksum: 10c0/4c4cfa214a613e794b8e62e4d139321d9bb5b10e13418a2450257c178adacff4d859b77ed3c367d273fb116fa2e5d6d2e9def0ae194555c4bc95b790de7feebf + languageName: node + linkType: hard + "fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0": version: 2.1.0 resolution: "fast-json-stable-stringify@npm:2.1.0" @@ -4897,7 +4916,20 @@ __metadata: languageName: node linkType: hard -"globby@npm:^14.0.2, globby@npm:^14.1.0": +"globby@npm:^13.0.0": + version: 13.2.2 + resolution: "globby@npm:13.2.2" + dependencies: + dir-glob: "npm:^3.0.1" + fast-glob: "npm:^3.3.0" + ignore: "npm:^5.2.4" + merge2: "npm:^1.4.1" + slash: "npm:^4.0.0" + checksum: 10c0/a8d7cc7cbe5e1b2d0f81d467bbc5bc2eac35f74eaded3a6c85fc26d7acc8e6de22d396159db8a2fc340b8a342e74cac58de8f4aee74146d3d146921a76062664 + languageName: node + linkType: hard + +"globby@npm:^14.1.0": version: 14.1.0 resolution: "globby@npm:14.1.0" dependencies: @@ -6100,13 +6132,9 @@ __metadata: "@lage-run/cli": "workspace:^" "@lage-run/monorepo-scripts": "workspace:^" "@lage-run/runners": "workspace:^" - backfill-config: "npm:6.7.1" - dts-bundle-generator: "npm:^9.5.1" esbuild: "npm:^0.25.0" - esbuild-plugin-alias: "npm:^0.2.1" fsevents: "npm:~2.3.2" glob-hasher: "npm:^1.4.2" - workspace-tools: "npm:0.41.0" dependenciesMeta: fsevents: optional: true @@ -7576,6 +7604,13 @@ __metadata: languageName: node linkType: hard +"slash@npm:^4.0.0": + version: 4.0.0 + resolution: "slash@npm:4.0.0" + checksum: 10c0/b522ca75d80d107fd30d29df0549a7b2537c83c4c4ecd12cd7d4ea6c8aaca2ab17ada002e7a1d78a9d736a0261509f26ea5b489082ee443a3a810586ef8eff18 + languageName: node + linkType: hard + "slash@npm:^5.1.0": version: 5.1.0 resolution: "slash@npm:5.1.0" @@ -8645,3 +8680,10 @@ __metadata: checksum: 10c0/dceb44c28578b31641e13695d200d34ec4ab3966a5729814d5445b194933c096b7ced71494ce53a0e8820685d1d010df8b2422e5bf2cdea7e469d97ffbea306f languageName: node linkType: hard + +"zimmerframe@npm:^1.1.4": + version: 1.1.4 + resolution: "zimmerframe@npm:1.1.4" + checksum: 10c0/9470cbf22cefae975ab413c7158a119d082b354ddcf0da48a842f2f42246fa15943cd9b92c047de39db38015e3b866e32f383bc217e8e4f4192945c7d425536b + languageName: node + linkType: hard