Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
},
"runtimeArgs": [],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"protocol": "inspector"
"cwd": "${workspaceRoot}"
},
{
"name": "Debug current open test",
Expand All @@ -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
}
]
}
232 changes: 232 additions & 0 deletions .yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch
Original file line number Diff line number Diff line change
@@ -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}`;
104 changes: 104 additions & 0 deletions .yarn/patches/fast-glob-npm-3.3.3-2a653be532.patch
Original file line number Diff line number Diff line change
@@ -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 @@
-/// <reference types="node" />
-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<OptionsInternal, 'objectMode'>]-?: true;
-};
-type EntryStatsPredicate = {
- [TKey in keyof Pick<OptionsInternal, 'stats'>]-?: true;
-};
-type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate;
-declare function FastGlob(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): Promise<EntryInternal[]>;
-declare function FastGlob(source: PatternInternal | PatternInternal[], options?: OptionsInternal): Promise<string[]>;
+//
+// 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 @@
/// <reference types="node" />
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<string, Pattern[]>;
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;
18 changes: 18 additions & 0 deletions change/change-9115f1bd-4c91-4311-af52-c634603f5a27.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
1 change: 1 addition & 0 deletions lage.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading