@ms-cloudpack/config 0.28.7 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/createPackageSettingsTransform.js +24 -9
- package/lib/createPackageSettingsTransform.js.map +1 -1
- package/lib/readAppConfig.js +1 -1
- package/lib/readAppConfig.js.map +1 -1
- package/lib/readConfig.d.ts.map +1 -1
- package/lib/readConfig.js +15 -9
- package/lib/readConfig.js.map +1 -1
- package/lib/resolveParentConfig.js +1 -1
- package/lib/resolveParentConfig.js.map +1 -1
- package/package.json +4 -5
- package/lib/resolveModule.d.ts +0 -9
- package/lib/resolveModule.d.ts.map +0 -1
- package/lib/resolveModule.js +0 -15
- package/lib/resolveModule.js.map +0 -1
|
@@ -82,7 +82,9 @@ function computeDependencies(options) {
|
|
|
82
82
|
async function computeExports(options, context) {
|
|
83
83
|
const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;
|
|
84
84
|
const { appPath, routes } = context.config;
|
|
85
|
-
//
|
|
85
|
+
// TODO: an array of export objects is not really valid per the spec and most implementations
|
|
86
|
+
const exports = [];
|
|
87
|
+
// If this is the app package and it has routes with entries, use those to create the exports map.
|
|
86
88
|
if (slash(appPath) === slash(packagePath) && routes?.length) {
|
|
87
89
|
const routeExports = {};
|
|
88
90
|
for (const route of routes) {
|
|
@@ -101,23 +103,36 @@ async function computeExports(options, context) {
|
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
if (Object.keys(routeExports).length) {
|
|
104
|
-
//
|
|
105
|
-
// be pulled from package.json.
|
|
106
|
+
// Currently route exports take precedence over all other exports for the app package.
|
|
106
107
|
return routeExports;
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
// TODO: an array of export objects is not really valid per the spec and most implementations
|
|
110
|
-
const exports = [];
|
|
111
110
|
// Push exports from the package.
|
|
112
|
-
|
|
113
|
-
definition.
|
|
114
|
-
|
|
111
|
+
if (userPackageSettings?.exports !== undefined) {
|
|
112
|
+
// Prefer user settings over the original definition, including respecting null (remove exports).
|
|
113
|
+
if (userPackageSettings.exports !== null) {
|
|
114
|
+
exports.push(userPackageSettings.exports);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (definition.exports !== undefined) {
|
|
118
|
+
// Or take the original exports if specified (again respecting null)
|
|
119
|
+
if (definition.exports !== null) {
|
|
120
|
+
exports.push(definition.exports);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Otherwise, generate an exports map from any other given entry points.
|
|
125
|
+
exports.push(await getExportsMap({ packagePath, disableTransforms: true }, context));
|
|
126
|
+
}
|
|
115
127
|
// Push generated exports.
|
|
116
128
|
if (generatedPackageSettings?.exports) {
|
|
117
129
|
exports.push(generatedPackageSettings.exports);
|
|
118
130
|
}
|
|
119
131
|
if (exports.length === 0) {
|
|
120
|
-
|
|
132
|
+
// If nothing was pushed to the array, this means the exports from either user package settings
|
|
133
|
+
// or the original definition must have been null (and we have no route or generated exports),
|
|
134
|
+
// so respect that.
|
|
135
|
+
return null;
|
|
121
136
|
}
|
|
122
137
|
if (exports.length === 1) {
|
|
123
138
|
return exports[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPackageSettingsTransform.js","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAiC,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,MAAM,EAAE,IAAI,EAAE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Y;oBACrB,WAAW;oBACX,oBAAoB,EAAE,SAAS;oBAC/B,QAAQ,EAAE,SAAS,CAAC,UAAU;oBAC9B,UAAU,EAAE,SAAS,CAAC,UAAU;iBACjC,EACD,OAAO,CACR,CAAC;YACJ,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,CAAC;YACrC,uFAAuF;YACvF,+BAA+B;YAC/B,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,6FAA6F;IAC7F,MAAM,OAAO,GAAyB,EAAE,CAAC;IAEzC,iCAAiC;IACjC,OAAO,CAAC,IAAI,CACV,mBAAmB,EAAE,OAAO;QAC1B,UAAU,CAAC,OAAO;QAClB,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAC3E,CAAC;IAEF,0BAA0B;IAC1B,IAAI,wBAAwB,EAAE,OAAO,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n CloudpackConfig,\n PackageDefinitionTransform,\n PackageDefinitionsCache,\n PackageJson,\n PackageJsonDependencies,\n PackageJsonExports,\n PackageJsonExportsObject,\n RenderedRoute,\n} from '@ms-cloudpack/common-types';\nimport { addExportsMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { getPackageSettings, type GetPackageSettingsResult } from './getPackageSettings.js';\nimport { mergePackageSettings } from './mergePackageSettings.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for updating package.json\n * based on package settings from the config.\n */\nexport function createPackageSettingsTransform(config: CloudpackConfig): PackageDefinitionTransform {\n return async ({ definition, packagePath, packages }) => {\n const { name, version } = definition;\n\n const { userPackageSettings, generatedPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n\n // Exclude all things not important in preserving within the package.json. This limits what we end up hashing\n // when we hash the definition.\n const { exports, includedDependencies, excludedDependencies, ...settings } = mergePackageSettings([\n userPackageSettings || {},\n generatedPackageSettings || {},\n ]);\n\n const newDefinition: PackageJson = {\n name,\n version,\n exports: await computeExports(\n { packagePath, definition, userPackageSettings, generatedPackageSettings },\n { packages, config },\n ),\n dependencies: computeDependencies({ definition, userPackageSettings, generatedPackageSettings }),\n };\n\n if (definition.peerDependencies && !userPackageSettings?.excludedDependencies?.includes('$peerDependencies')) {\n newDefinition.peerDependencies = !excludedDependencies?.length\n ? definition.peerDependencies\n : Object.fromEntries(\n Object.entries(definition.peerDependencies).filter(([dep]) => !excludedDependencies.includes(dep)),\n );\n }\n\n if (config.mode || Object.keys(settings).length > 0) {\n newDefinition.cloudpack = {\n mode: config.mode,\n ...settings,\n };\n }\n\n return newDefinition;\n };\n}\n\nfunction computeDependencies(\n options: GetPackageSettingsResult & {\n definition: PackageJson;\n },\n): PackageJsonDependencies {\n const { definition, userPackageSettings, generatedPackageSettings } = options;\n const { dependencies = {} } = definition;\n const newDependencies = { ...dependencies };\n\n // If we have included dependencies, add them.\n const includedDependencies = [\n ...(userPackageSettings?.includedDependencies || []),\n ...(generatedPackageSettings?.includedDependencies || []),\n ];\n\n // Expand the $devDependencies placeholder to the actual dev dependencies.\n const includeDevDependencies = includedDependencies.indexOf('$devDependencies');\n\n if (includeDevDependencies !== -1) {\n includedDependencies.splice(includeDevDependencies, 1, ...Object.keys(definition.devDependencies || {}));\n }\n\n // Add the dependency from other sources, or use a wildcard.\n for (const dep of includedDependencies) {\n newDependencies[dep] =\n definition.dependencies?.[dep] ||\n definition.devDependencies?.[dep] ||\n definition.peerDependencies?.[dep] ||\n definition.optionalDependencies?.[dep] ||\n '*';\n }\n\n const excludedDependencies = [\n ...(userPackageSettings?.excludedDependencies || []),\n ...(generatedPackageSettings?.excludedDependencies || []),\n ];\n\n // Expand the $peerDependencies placeholder to the actual peer dependencies.\n const excludePeerDependencies = excludedDependencies.indexOf('$peerDependencies');\n\n if (excludePeerDependencies !== -1) {\n // Add peer dependencies to the list of excluded dependencies.\n excludedDependencies.splice(excludePeerDependencies, 1, ...Object.keys(definition.peerDependencies || {}));\n }\n\n for (const dep of excludedDependencies) {\n delete newDependencies[dep];\n }\n\n return newDependencies;\n}\n\nasync function computeExports(\n options: GetPackageSettingsResult & {\n packagePath: string;\n definition: PackageJson;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports | undefined> {\n const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;\n const { appPath, routes } = context.config;\n\n // If this is the app package and it has routes with entries, use those to define the exports map.\n if (slash(appPath) === slash(packagePath) && routes?.length) {\n const routeExports: PackageJsonExportsObject = {};\n\n for (const route of routes) {\n const { entry } = route as RenderedRoute;\n if (!entry?.length) {\n continue;\n }\n\n for (const entryItem of entry) {\n await addExportsMapEntry(\n {\n exports: routeExports,\n packagePath,\n environmentCondition: 'browser',\n filePath: entryItem.sourcePath,\n importPath: entryItem.importPath,\n },\n context,\n );\n }\n }\n\n if (Object.keys(routeExports).length) {\n // We short circuit here because we don't want to include any unused exports that might\n // be pulled from package.json.\n return routeExports;\n }\n }\n\n // TODO: an array of export objects is not really valid per the spec and most implementations\n const exports: PackageJsonExports[] = [];\n\n // Push exports from the package.\n exports.push(\n userPackageSettings?.exports ||\n definition.exports ||\n (await getExportsMap({ packagePath, disableTransforms: true }, context)),\n );\n\n // Push generated exports.\n if (generatedPackageSettings?.exports) {\n exports.push(generatedPackageSettings.exports);\n }\n\n if (exports.length === 0) {\n return undefined;\n }\n\n if (exports.length === 1) {\n return exports[0];\n }\n\n return exports;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createPackageSettingsTransform.js","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAiC,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;QAErC,MAAM,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,GAAG,kBAAkB,CAAC;YAC3E,IAAI;YACJ,OAAO;YACP,mBAAmB,EAAE,MAAM,CAAC,eAAe;YAC3C,wBAAwB,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe;SAC3D,CAAC,CAAC;QAEH,6GAA6G;QAC7G,+BAA+B;QAC/B,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,QAAQ,EAAE,GAAG,oBAAoB,CAAC;YAChG,mBAAmB,IAAI,EAAE;YACzB,wBAAwB,IAAI,EAAE;SAC/B,CAAC,CAAC;QAEH,MAAM,aAAa,GAAgB;YACjC,IAAI;YACJ,OAAO;YACP,OAAO,EAAE,MAAM,cAAc,CAC3B,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,EAC1E,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrB;YACD,YAAY,EAAE,mBAAmB,CA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AAoE;QACpE,IAAI,UAAU,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAChC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,wEAAwE;QACxE,OAAO,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,0BAA0B;IAC1B,IAAI,wBAAwB,EAAE,OAAO,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,+FAA+F;QAC/F,8FAA8F;QAC9F,mBAAmB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n CloudpackConfig,\n PackageDefinitionTransform,\n PackageDefinitionsCache,\n PackageJson,\n PackageJsonDependencies,\n PackageJsonExports,\n PackageJsonExportsObject,\n RenderedRoute,\n} from '@ms-cloudpack/common-types';\nimport { addExportsMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { slash } from '@ms-cloudpack/path-string-parsing';\nimport { getPackageSettings, type GetPackageSettingsResult } from './getPackageSettings.js';\nimport { mergePackageSettings } from './mergePackageSettings.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for updating package.json\n * based on package settings from the config.\n */\nexport function createPackageSettingsTransform(config: CloudpackConfig): PackageDefinitionTransform {\n return async ({ definition, packagePath, packages }) => {\n const { name, version } = definition;\n\n const { userPackageSettings, generatedPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n\n // Exclude all things not important in preserving within the package.json. This limits what we end up hashing\n // when we hash the definition.\n const { exports, includedDependencies, excludedDependencies, ...settings } = mergePackageSettings([\n userPackageSettings || {},\n generatedPackageSettings || {},\n ]);\n\n const newDefinition: PackageJson = {\n name,\n version,\n exports: await computeExports(\n { packagePath, definition, userPackageSettings, generatedPackageSettings },\n { packages, config },\n ),\n dependencies: computeDependencies({ definition, userPackageSettings, generatedPackageSettings }),\n };\n\n if (definition.peerDependencies && !userPackageSettings?.excludedDependencies?.includes('$peerDependencies')) {\n newDefinition.peerDependencies = !excludedDependencies?.length\n ? definition.peerDependencies\n : Object.fromEntries(\n Object.entries(definition.peerDependencies).filter(([dep]) => !excludedDependencies.includes(dep)),\n );\n }\n\n if (config.mode || Object.keys(settings).length > 0) {\n newDefinition.cloudpack = {\n mode: config.mode,\n ...settings,\n };\n }\n\n return newDefinition;\n };\n}\n\nfunction computeDependencies(\n options: GetPackageSettingsResult & {\n definition: PackageJson;\n },\n): PackageJsonDependencies {\n const { definition, userPackageSettings, generatedPackageSettings } = options;\n const { dependencies = {} } = definition;\n const newDependencies = { ...dependencies };\n\n // If we have included dependencies, add them.\n const includedDependencies = [\n ...(userPackageSettings?.includedDependencies || []),\n ...(generatedPackageSettings?.includedDependencies || []),\n ];\n\n // Expand the $devDependencies placeholder to the actual dev dependencies.\n const includeDevDependencies = includedDependencies.indexOf('$devDependencies');\n\n if (includeDevDependencies !== -1) {\n includedDependencies.splice(includeDevDependencies, 1, ...Object.keys(definition.devDependencies || {}));\n }\n\n // Add the dependency from other sources, or use a wildcard.\n for (const dep of includedDependencies) {\n newDependencies[dep] =\n definition.dependencies?.[dep] ||\n definition.devDependencies?.[dep] ||\n definition.peerDependencies?.[dep] ||\n definition.optionalDependencies?.[dep] ||\n '*';\n }\n\n const excludedDependencies = [\n ...(userPackageSettings?.excludedDependencies || []),\n ...(generatedPackageSettings?.excludedDependencies || []),\n ];\n\n // Expand the $peerDependencies placeholder to the actual peer dependencies.\n const excludePeerDependencies = excludedDependencies.indexOf('$peerDependencies');\n\n if (excludePeerDependencies !== -1) {\n // Add peer dependencies to the list of excluded dependencies.\n excludedDependencies.splice(excludePeerDependencies, 1, ...Object.keys(definition.peerDependencies || {}));\n }\n\n for (const dep of excludedDependencies) {\n delete newDependencies[dep];\n }\n\n return newDependencies;\n}\n\nasync function computeExports(\n options: GetPackageSettingsResult & {\n packagePath: string;\n definition: PackageJson;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports | undefined> {\n const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;\n const { appPath, routes } = context.config;\n\n // TODO: an array of export objects is not really valid per the spec and most implementations\n const exports: PackageJsonExports[] = [];\n\n // If this is the app package and it has routes with entries, use those to create the exports map.\n if (slash(appPath) === slash(packagePath) && routes?.length) {\n const routeExports: PackageJsonExportsObject = {};\n\n for (const route of routes) {\n const { entry } = route as RenderedRoute;\n if (!entry?.length) {\n continue;\n }\n\n for (const entryItem of entry) {\n await addExportsMapEntry(\n {\n exports: routeExports,\n packagePath,\n environmentCondition: 'browser',\n filePath: entryItem.sourcePath,\n importPath: entryItem.importPath,\n },\n context,\n );\n }\n }\n\n if (Object.keys(routeExports).length) {\n // Currently route exports take precedence over all other exports for the app package.\n return routeExports;\n }\n }\n\n // Push exports from the package.\n if (userPackageSettings?.exports !== undefined) {\n // Prefer user settings over the original definition, including respecting null (remove exports).\n if (userPackageSettings.exports !== null) {\n exports.push(userPackageSettings.exports);\n }\n } else if (definition.exports !== undefined) {\n // Or take the original exports if specified (again respecting null)\n if (definition.exports !== null) {\n exports.push(definition.exports);\n }\n } else {\n // Otherwise, generate an exports map from any other given entry points.\n exports.push(await getExportsMap({ packagePath, disableTransforms: true }, context));\n }\n\n // Push generated exports.\n if (generatedPackageSettings?.exports) {\n exports.push(generatedPackageSettings.exports);\n }\n\n if (exports.length === 0) {\n // If nothing was pushed to the array, this means the exports from either user package settings\n // or the original definition must have been null (and we have no route or generated exports),\n // so respect that.\n return null;\n }\n\n if (exports.length === 1) {\n return exports[0];\n }\n\n return exports;\n}\n"]}
|
package/lib/readAppConfig.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readJson } from '@ms-cloudpack/json-utilities';
|
|
|
2
2
|
import { getConfigPath } from './getConfigPath.js';
|
|
3
3
|
import { mergeParentConfig } from './mergeParentConfig.js';
|
|
4
4
|
import { resolveParentConfig } from './resolveParentConfig.js';
|
|
5
|
-
import { resolveModule } from '
|
|
5
|
+
import { resolveModule } from '@ms-cloudpack/package-utilities';
|
|
6
6
|
/**
|
|
7
7
|
* Reads the user config file and merges with any parent configs asynchronously.
|
|
8
8
|
* Note this is only useful for making modifications to the user config.
|
package/lib/readAppConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../src/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../src/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,CAAC,K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O,uBAAuB,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;AAClF,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,MAAiB;IAChD,sCAAsC;IACtC,MAAM,EAAE,SAAS,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAEnD,IAAI,SAAS,EAAE,MAAM,EAAE,CAAC;QACtB,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;QACjC,OAAO,SAAS,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;YACtC,OAAO,OAAO,CAAC,WAAW,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;IACd,qCAAqC;AACvC,CAAC","sourcesContent":["import type { AppConfig, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { resolveModule } from '@ms-cloudpack/package-utilities';\n\n/**\n * Reads the user config file and merges with any parent configs asynchronously.\n * Note this is only useful for making modifications to the user config.\n * For a full merged representation of config, use `readConfig` instead.\n *\n * Throws an error if the config file exists but is not valid JSON (or there's some error reading it).\n */\nexport async function readAppConfig(appPath: string): Promise<AppConfig> {\n const { appConfigPath } = getConfigPath(appPath);\n\n return (await readAppConfigInternal(appConfigPath)) || {};\n}\n\nfunction tryResolveBundlerCapability(importSpecifier: string, parentUrl: string) {\n try {\n return resolveModule({ parentUrl, importSpecifier });\n } catch (e) {\n console.warn(`Error resolving bundler capability \"${importSpecifier}\", Error:`, e);\n return undefined;\n }\n}\n\n/**\n * Reads the user config, with any `extends` parent configs merged in.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n */\nasync function readAppConfigInternal(configPath: string): Promise<AppConfig | undefined> {\n const AppConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!AppConfig) {\n return undefined;\n }\n\n // Resolve import specifiers for bundler capabilities registry\n if (AppConfig.bundlerCapabilitiesRegistry) {\n for (const [key, value] of Object.entries(AppConfig.bundlerCapabilitiesRegistry)) {\n const moduleUrl = tryResolveBundlerCapability(value, configPath);\n if (moduleUrl) {\n AppConfig.bundlerCapabilitiesRegistry[key] = moduleUrl;\n }\n }\n }\n\n // PackageSettings's bundlerCapabilities may contain short-hand keys that need to be resolved to full import specifiers before bundler capabilities can be processed\n // This is done by looking up the short-hand keys in the bundlerCapabilitiesRegistry\n // If the short-hand key is not found in the registry, it is assumed to be a full import specifier\n if (AppConfig.packageSettings && AppConfig.bundlerCapabilitiesRegistry) {\n for (const setting of AppConfig.packageSettings) {\n if (setting.bundlerCapabilities) {\n const newBundlerCapabilities: BundlerCapabilitiesOptions = {};\n for (const key in setting.bundlerCapabilities) {\n if (key in AppConfig.bundlerCapabilitiesRegistry) {\n const newKey = AppConfig.bundlerCapabilitiesRegistry[key];\n newBundlerCapabilities[newKey] = setting.bundlerCapabilities[key];\n } else {\n newBundlerCapabilities[key] = setting.bundlerCapabilities[key];\n }\n }\n setting.bundlerCapabilities = newBundlerCapabilities;\n }\n }\n }\n\n const extendsArray = AppConfig.extends\n ? Array.isArray(AppConfig.extends)\n ? AppConfig.extends\n : [AppConfig.extends]\n : [];\n\n // Recursively read any parent config files\n const parentConfigs: AppConfig[] = [];\n for (const importSpecifier of extendsArray) {\n const resolvedPath = resolveParentConfig({ configPath, importSpecifier });\n if (resolvedPath) {\n const parentConfig = await readAppConfigInternal(resolvedPath);\n if (parentConfig) {\n parentConfigs.push(parentConfig);\n }\n }\n }\n\n return processDeprecatedValues(mergeParentConfig({ AppConfig, parentConfigs }));\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig) {\n /* eslint-disable etc/no-deprecated */\n const { devServer, packageSettings = [] } = config;\n\n if (devServer?.routes) {\n config.routes = devServer.routes;\n delete devServer.routes;\n }\n\n for (const setting of packageSettings) {\n if (setting.bundlerType) {\n setting.bundler = setting.bundlerType;\n delete setting.bundlerType;\n }\n }\n\n return config;\n /* eslint-enable etc/no-deprecated */\n}\n"]}
|
package/lib/readConfig.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;AAgBpC;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,UAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CAiBxG"}
|
package/lib/readConfig.js
CHANGED
|
@@ -5,6 +5,7 @@ import { intermediateToSourcePath, sourceToIntermediatePath } from '@ms-cloudpac
|
|
|
5
5
|
import { flattenExportsMap } from '@ms-cloudpack/package-utilities';
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { readJsonSync } from '@ms-cloudpack/json-utilities';
|
|
8
|
+
import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
8
9
|
/**
|
|
9
10
|
* Reads the config file asynchronously (and merges generated config into the result.)
|
|
10
11
|
*/
|
|
@@ -28,8 +29,8 @@ export async function readConfig(appPath, mode = 'library') {
|
|
|
28
29
|
* Ensure all source entries in routes are expanded to fully qualified entry paths.
|
|
29
30
|
*/
|
|
30
31
|
function expandRoutes(routes, appPath) {
|
|
31
|
-
// Cached flattened exports for appPath, used to expand
|
|
32
|
-
|
|
32
|
+
// Cached flattened exports for appPath, used to expand entries
|
|
33
|
+
const flattenedExports = getFlattenedExports(appPath);
|
|
33
34
|
return routes.map((route) => {
|
|
34
35
|
if (!isShorthandRenderedRoute(route) && !isShorthandBootstrapRoute(route)) {
|
|
35
36
|
// Skip extra processing for other route types.
|
|
@@ -40,11 +41,10 @@ function expandRoutes(routes, appPath) {
|
|
|
40
41
|
const renderedRoute = rest;
|
|
41
42
|
if (entry?.length) {
|
|
42
43
|
// Expand the entry to full info about the file path.
|
|
43
|
-
renderedRoute.entry = expandEntry(entry, appPath);
|
|
44
|
+
renderedRoute.entry = expandEntry({ entry, appPath, flattenedExports });
|
|
44
45
|
}
|
|
45
46
|
if (exportEntry) {
|
|
46
47
|
// Handle backwards compatibility with moving from exportEntry to entry.
|
|
47
|
-
flattenedExports ??= getFlattenedExports(appPath);
|
|
48
48
|
const filePath = flattenedExports[exportEntry];
|
|
49
49
|
if (!filePath) {
|
|
50
50
|
throw new Error(`A route referenced exportEntry "${exportEntry}" but this couldn't be resolved from the package.json.`);
|
|
@@ -56,9 +56,15 @@ function expandRoutes(routes, appPath) {
|
|
|
56
56
|
return renderedRoute;
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
function expandEntry(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
function expandEntry(params) {
|
|
60
|
+
const { entry, appPath, flattenedExports } = params;
|
|
61
|
+
const entryArray = Array.isArray(entry) ? entry : entry !== undefined ? [entry] : [];
|
|
62
|
+
return entryArray.map((entryPath) => expandRouteEntry({
|
|
63
|
+
// Usually entryPath will be a source path, but also handle if it's an exports map key.
|
|
64
|
+
importPath: flattenedExports[entryPath] ? entryPath : undefined,
|
|
65
|
+
filePath: flattenedExports[entryPath] || entryPath,
|
|
66
|
+
appPath,
|
|
67
|
+
}));
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* Get flattened exports from package.json at `appPath`.
|
|
@@ -82,8 +88,8 @@ function expandRouteEntry(options) {
|
|
|
82
88
|
return {
|
|
83
89
|
// Used to derive bundle entry path
|
|
84
90
|
sourcePath,
|
|
85
|
-
//
|
|
86
|
-
importPath: importPath
|
|
91
|
+
// Import map key
|
|
92
|
+
importPath: importPath ? normalizeRelativePath(importPath) : sourceToIntermediatePath(sourcePath),
|
|
87
93
|
};
|
|
88
94
|
}
|
|
89
95
|
//# sourceMappingURL=readConfig.js.map
|
package/lib/readConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB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C,CAAC,SAAS;QAC/D,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,IAAI,SAAS;QAClD,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,OAAe;IAC1C,6FAA6F;IAC7F,8CAA8C;IAC9C,MAAM,UAAU,GAAG,YAAY,CAAqB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9F,MAAM,WAAW,GAAuC,iBAAiB,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IACpG,WAAW,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC;IAC1D,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,iEAAiE;AACjE,SAAS,gBAAgB,CAAC,OAAmE;IAC3F,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,mCAAmC;QACnC,UAAU;QACV,iBAAiB;QACjB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,UAAU,CAAC;KAClG,CAAC;AACJ,CAAC","sourcesContent":["import type {\n BootstrapRoute,\n BundleMode,\n CloudpackConfig,\n ExpandedSourcePath,\n PackageJson,\n RenderedRoute,\n Route,\n ShorthandRenderedRoute,\n ShorthandRoute,\n} from '@ms-cloudpack/common-types';\nimport { isShorthandBootstrapRoute, isShorthandRenderedRoute } from '@ms-cloudpack/common-types';\nimport { readAppConfig } from './readAppConfig.js';\nimport { readGeneratedConfig } from './readGeneratedConfig.js';\nimport { intermediateToSourcePath, sourceToIntermediatePath } from '@ms-cloudpack/path-utilities';\nimport { flattenExportsMap } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { readJsonSync } from '@ms-cloudpack/json-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * package.json with only the keys used in this file, since we're missing some logic from\n * PackageDefinitions which is assumed in the full type.\n */\ntype PartialPackageJson = Pick<PackageJson, 'exports' | 'module' | 'main'>;\n\n/**\n * Reads the config file asynchronously (and merges generated config into the result.)\n */\nexport async function readConfig(appPath: string, mode: BundleMode = 'library'): Promise<CloudpackConfig> {\n const [appConfig, generatedConfig] = await Promise.all([readAppConfig(appPath), readGeneratedConfig(appPath)]);\n const config = {\n ...appConfig,\n appPath,\n mode,\n generated: generatedConfig,\n generatedSnapshot: structuredClone(generatedConfig),\n } as CloudpackConfig;\n\n // Expands all routes which refer to source files into fully transformed route objects.\n const routes = appConfig.routes;\n if (routes?.length) {\n config.routes = expandRoutes(routes, appPath);\n }\n\n return config;\n}\n\n/**\n * Ensure all source entries in routes are expanded to fully qualified entry paths.\n */\nfunction expandRoutes(routes: ShorthandRoute[], appPath: string): Route[] {\n // Cached flattened exports for appPath, used to expand entries\n const flattenedExports = getFlattenedExports(appPath);\n\n return routes.map((route) => {\n if (!isShorthandRenderedRoute(route) && !isShorthandBootstrapRoute(route)) {\n // Skip extra processing for other route types.\n return route;\n }\n\n // eslint-disable-next-line etc/no-deprecated\n const { entry, exportEntry, ...rest } = route;\n const renderedRoute: RenderedRoute | BootstrapRoute = rest;\n\n if (entry?.length) {\n // Expand the entry to full info about the file path.\n renderedRoute.entry = expandEntry({ entry, appPath, flattenedExports });\n }\n\n if (exportEntry) {\n // Handle backwards compatibility with moving from exportEntry to entry.\n const filePath = flattenedExports[exportEntry];\n if (!filePath) {\n throw new Error(\n `A route referenced exportEntry \"${exportEntry}\" but this couldn't be resolved from the package.json.`,\n );\n }\n\n const expanded = expandRouteEntry({ importPath: exportEntry, filePath, appPath });\n console.warn(\n 'The route property \"exportEntry\" is deprecated. Update your route as follows:',\n JSON.stringify({ ...renderedRoute, entry: expanded.sourcePath }, null, 2),\n );\n (renderedRoute.entry ??= []).push(expanded);\n }\n\n return renderedRoute;\n });\n}\n\nfunction expandEntry(params: {\n entry: ShorthandRenderedRoute['entry'];\n appPath: string;\n flattenedExports: Record<string, string | undefined>;\n}): ExpandedSourcePath[] {\n const { entry, appPath, flattenedExports } = params;\n const entryArray = Array.isArray(entry) ? entry : entry !== undefined ? [entry] : [];\n\n return entryArray.map((entryPath) =>\n expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[entryPath] ? entryPath : undefined,\n filePath: flattenedExports[entryPath] || entryPath,\n appPath,\n }),\n );\n}\n\n/**\n * Get flattened exports from package.json at `appPath`.\n * If there's no export for `.`, it will be filled in from `module || main`.\n */\nfunction getFlattenedExports(appPath: string): Record<string, string | undefined> {\n // We can't use PackageDefinitions.get here because we're reading the config, and definitions\n // cache requires config resulting in a cycle.\n const definition = readJsonSync<PartialPackageJson>(path.join(appPath, 'package.json')) || {};\n const flatExports: Record<string, string | undefined> = flattenExportsMap(definition.exports || {});\n flatExports['.'] ??= definition.module || definition.main;\n return flatExports;\n}\n\n/** Expands shorthand route entries into fully qualified ones. */\nfunction expandRouteEntry(options: { importPath?: string; filePath: string; appPath: string }): ExpandedSourcePath {\n const { filePath, appPath, importPath } = options;\n const sourcePath = intermediateToSourcePath(filePath, appPath);\n\n if (!sourcePath) {\n throw new Error(`Could not resolve source path for entry: ${filePath}`);\n }\n\n return {\n // Used to derive bundle entry path\n sourcePath,\n // Import map key\n importPath: importPath ? normalizeRelativePath(importPath) : sourceToIntermediatePath(sourcePath),\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'url';
|
|
2
|
-
import { resolveModule } from '
|
|
2
|
+
import { resolveModule } from '@ms-cloudpack/package-utilities';
|
|
3
3
|
/**
|
|
4
4
|
* Resolve an import specifier for a parent config file.
|
|
5
5
|
* Returns undefined if it can't be resolved or doesn't exist.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAKnC;IACC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAEnC,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,aAAa,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IACzF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,eAAe,MAAO,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { fileURLToPath } from 'url';\nimport { resolveModule } from '@ms-cloudpack/package-utilities';\n\n/**\n * Resolve an import specifier for a parent config file.\n * Returns undefined if it can't be resolved or doesn't exist.\n */\nexport function resolveParentConfig(params: {\n /** Path of the config file being processed. */\n configPath: string;\n /** The import specifier for the parent (extends) config file. */\n importSpecifier: string;\n}): string | undefined {\n const { importSpecifier } = params;\n\n try {\n return fileURLToPath(resolveModule({ importSpecifier, parentUrl: params.configPath }));\n } catch (err) {\n console.warn(`Error resolving config \"extends\": \"${importSpecifier}\": ${(err as Error).message || err}`);\n }\n\n return undefined;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.19.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.19.7",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.7",
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^10.0
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^10.1.0",
|
|
20
20
|
"@ms-cloudpack/path-string-parsing": "^1.2.4",
|
|
21
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
22
|
-
"import-meta-resolve": "^4.0.0",
|
|
21
|
+
"@ms-cloudpack/path-utilities": "^2.7.44",
|
|
23
22
|
"semver": "^7.6.0"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
package/lib/resolveModule.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
|
|
3
|
-
* @returns - The resolved file url as a string.
|
|
4
|
-
*/
|
|
5
|
-
export declare function resolveModule(params: {
|
|
6
|
-
importSpecifier: string;
|
|
7
|
-
parentUrl: string;
|
|
8
|
-
}): string;
|
|
9
|
-
//# sourceMappingURL=resolveModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModule.d.ts","sourceRoot":"","sources":["../src/resolveModule.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK5F"}
|
package/lib/resolveModule.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { moduleResolve } from 'import-meta-resolve';
|
|
2
|
-
import { pathToFileURL } from 'url';
|
|
3
|
-
// Conditions used for resolution if the package has an exports map.
|
|
4
|
-
// More could be added later if desired ("default" is implicitly included).
|
|
5
|
-
const conditions = new Set(['import', 'require', 'node']);
|
|
6
|
-
/**
|
|
7
|
-
* Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.
|
|
8
|
-
* @returns - The resolved file url as a string.
|
|
9
|
-
*/
|
|
10
|
-
export function resolveModule(params) {
|
|
11
|
-
const { importSpecifier, parentUrl } = params;
|
|
12
|
-
const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);
|
|
13
|
-
return resolvedUrl.toString();
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=resolveModule.js.map
|
package/lib/resolveModule.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveModule.js","sourceRoot":"","sources":["../src/resolveModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,oEAAoE;AACpE,2EAA2E;AAC3E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAsD;IAClF,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAE9C,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACzF,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;AAChC,CAAC","sourcesContent":["import { moduleResolve } from 'import-meta-resolve';\nimport { pathToFileURL } from 'url';\n\n// Conditions used for resolution if the package has an exports map.\n// More could be added later if desired (\"default\" is implicitly included).\nconst conditions = new Set(['import', 'require', 'node']);\n\n/**\n * Resolve a module specifier to a file url (with protocol ie: file:). Throws if it can't be resolved.\n * @returns - The resolved file url as a string.\n */\nexport function resolveModule(params: { importSpecifier: string; parentUrl: string }): string {\n const { importSpecifier, parentUrl } = params;\n\n const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);\n return resolvedUrl.toString();\n}\n"]}
|