@ms-cloudpack/config 0.38.3 → 0.38.4
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/builtInSettings/builtInSettings.d.ts.map +1 -1
- package/lib/builtInSettings/builtInSettings.js +57 -0
- package/lib/builtInSettings/builtInSettings.js.map +1 -1
- package/lib/readConfig/readAppConfig.d.ts +11 -1
- package/lib/readConfig/readAppConfig.d.ts.map +1 -1
- package/lib/readConfig/readAppConfig.js +21 -8
- package/lib/readConfig/readAppConfig.js.map +1 -1
- package/lib/readConfig/readConfig.d.ts.map +1 -1
- package/lib/readConfig/readConfig.js +7 -1
- package/lib/readConfig/readConfig.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtInSettings.d.ts","sourceRoot":"","sources":["../../src/builtInSettings/builtInSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG/E,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC;IAC7D;;;;OAIG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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} from './deepFreeze.js';
|
|
|
12
12
|
* only package settings.)
|
|
13
13
|
*/
|
|
14
14
|
export const builtInSettings = deepFreeze({
|
|
15
|
+
'@fluentai/flair': {
|
|
16
|
+
'>=0 <1.0.0': {
|
|
17
|
+
// Use rollup as esbuild translates classes incorrectly
|
|
18
|
+
packageSettings: { bundler: 'rollup' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
'@fluentui/react-bindings': {
|
|
22
|
+
'>=0 <1.0.0': {
|
|
23
|
+
// Use rollup to preserve export *
|
|
24
|
+
packageSettings: { bundler: 'rollup' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
'@fluentui/react-northstar': {
|
|
28
|
+
'>=0 <1.0.0': {
|
|
29
|
+
// Use rollup to preserve export *
|
|
30
|
+
packageSettings: { bundler: 'rollup' },
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
'@fluid-internal/client-utils': {
|
|
34
|
+
'>=0 <3.0.0': {
|
|
35
|
+
// This package mixes CJS and ESM which causes problems for ori.
|
|
36
|
+
packageSettings: { bundler: 'rollup' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
'@microsoft/objectstoreprovider': {
|
|
40
|
+
'>=0 <1.0.0': {
|
|
41
|
+
// It is a CJS package with a declared side effect, we need webpack/rspack to respect it.
|
|
42
|
+
packageSettings: {
|
|
43
|
+
bundler: 'rspack',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
15
47
|
'@microsoft/recognizers-text-date-time': {
|
|
16
48
|
'^1.0.0': {
|
|
17
49
|
// This has a "browser" entry which doesn't provide exports correctly in the browser when bundled??
|
|
@@ -58,6 +90,17 @@ export const builtInSettings = deepFreeze({
|
|
|
58
90
|
},
|
|
59
91
|
},
|
|
60
92
|
},
|
|
93
|
+
color: {
|
|
94
|
+
'>=0 <6.0.0': {
|
|
95
|
+
packageSettings: {
|
|
96
|
+
// This package iterates through the keys of "color-convert" and errors on a default key.
|
|
97
|
+
// It is a small package so we can inline all its dependencies and use ori instead of rollup.
|
|
98
|
+
inlinedDependencies: ['color-convert', 'color-string'],
|
|
99
|
+
excludedDependencies: ['color-convert', 'color-string'],
|
|
100
|
+
bundler: 'ori',
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
61
104
|
'gql.tada': {
|
|
62
105
|
'^1.0.0': {
|
|
63
106
|
// This package has a combination of browser and CLI code.
|
|
@@ -103,6 +146,20 @@ export const builtInSettings = deepFreeze({
|
|
|
103
146
|
},
|
|
104
147
|
},
|
|
105
148
|
},
|
|
149
|
+
'office-ui-fabric-react': {
|
|
150
|
+
'>=0 <8.0.0': {
|
|
151
|
+
// Use rollup to preserve export *
|
|
152
|
+
packageSettings: { bundler: 'rollup' },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
postcss: {
|
|
156
|
+
// The package added a .mjs as a stub. This confuses cloudpack and we try to bundle with ori and fail
|
|
157
|
+
'^8.0.0': {
|
|
158
|
+
packageJson: {
|
|
159
|
+
exports: './lib/postcss.js',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
106
163
|
react: {
|
|
107
164
|
'^16.14.0 || ^17.0.0': {
|
|
108
165
|
// Package is missing an exports map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtInSettings.js","sourceRoot":"","sources":["../../src/builtInSettings/builtInSettings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAMvC;IACA,uCAAuC,EAAE;QACvC,QAAQ,EAAE;YACR,mGAAmG;YACnG,sDAAsD;YACtD,wEAAwE;YACxE,WAAW,EAAE;gBACX,OAAO,EAAE,0CAA0C;aACpD;SACF;KACF;IAED,IAAI,EAAE;QACJ,QAAQ,EAAE;YACR,sFAAsF;YACtF,gFAAgF;YAChF,+EAA+E;YAC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X,OAAO,EAAE;oBACP,GAAG,EAAE,YAAY;oBACjB,eAAe,EAAE,kBAAkB;oBACnC,mBAAmB,EAAE,sBAAsB;iBAC5C;aACF;SACF;KACF;IAED,SAAS,EAAE;QACT,aAAa,EAAE;YACb,oCAAoC;YACpC,yDAAyD;YACzD,WAAW,EAAE;gBACX,OAAO,EAAE;oBACP,GAAG,EAAE,YAAY;oBACjB,WAAW,EAAE,cAAc;iBAC5B;aACF;SACF;QACD,iBAAiB,EAAE;YACjB,oCAAoC;YACpC,yDAAyD;YACzD,WAAW,EAAE;gBACX,OAAO,EAAE,YAAY;aACtB;SACF;KACF;IAED,kBAAkB,EAAE;QAClB,QAAQ,EAAE;YACR,0BAA0B;YAC1B,2DAA2D;YAC3D,WAAW,EAAE;gBACX,OAAO,EAAE,sBAAsB;aAChC;SACF;KACF;IAED,iBAAiB,EAAE;QACjB,wCAAwC;QACxC,6EAA6E;QAC7E,wGAAwG;QACxG,oCAAoC;QACpC,YAAY,EAAE;YACZ,aAAa;YACb,eAAe,EAAE;gBACf,OAAO,EAAE,QAAQ;aAClB;SACF;KACF;IAED,KAAK,EAAE;QACL,YAAY,EAAE;YACZ,0BAA0B;YAC1B,oDAAoD;YACpD,WAAW,EAAE;gBACX,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,QAAQ,EAAE;YACR,0BAA0B;YAC1B,oDAAoD;YACpD,WAAW,EAAE;gBACX,OAAO,EAAE,iBAAiB;aAC3B;SACF;KACF;IAED,wDAAwD;CACzD,CAAC,CAAC","sourcesContent":["import type { PackageJson, PackageSettings } from '@ms-cloudpack/common-types';\nimport { deepFreeze } from './deepFreeze.js';\n\nexport interface BuiltInSettings {\n /**\n * Package settings to automatically apply for this package name/version.\n * (These are merged by `getPackageSettings`, mostly as called by `createPackageSettingsTransform`.)\n */\n packageSettings?: Omit<PackageSettings, 'match' | 'exports'>;\n /**\n * package.json settings to automatically apply for this package name/version.\n * These **overwrite** original properties of the `package.json` and are applied by\n * `PackageDefinitions` using `createBuiltInSettingsTransform`.\n */\n packageJson?: Omit<PackageJson, 'name' | 'version' | 'cloudpack'>;\n}\n\n/**\n * Mapping from package name to version range to built-in settings.\n *\n * This object is frozen to prevent accidental modification.\n *\n * The reason we're handling package.json modifications (just `exports` as of writing) and\n * `PackageSettings` separately is mainly to get around issues with merging exports maps.\n * https://github.com/microsoft/cloudpack/pull/2452#discussion_r1835192676\n * (If the exports merging issue is fixed in the future, and we don't find any cases where we want\n * to override other package.json properties, they could potentially be combined and handled with\n * only package settings.)\n */\nexport const builtInSettings = deepFreeze<\n Partial<{\n [packageName: string]: {\n [versionRange: string]: BuiltInSettings;\n };\n }>\n>({\n '@microsoft/recognizers-text-date-time': {\n '^1.0.0': {\n // This has a \"browser\" entry which doesn't provide exports correctly in the browser when bundled??\n // Switching to the regular entry point makes it work.\n // https://unpkg.com/browse/@microsoft/recognizers-text-date-time@1.3.2/\n packageJson: {\n exports: './dist/recognizers-text-date-time.es5.js',\n },\n },\n },\n\n asap: {\n '^2.0.0': {\n // This package has different browser and non-browser versions in the \"browser\" field.\n // Trying to bundle it with rollup (which creates an ESM stub) gives this error:\n // [ESM stub generation] /<repo path>/node_modules/asap/browser-asap.js:10:33\n // Error creating stub for entry \"./browser-asap\":\n // TypeError: rawAsap.makeRequestCallFromTimer is not a function\n // It's not clear why this happens, but bundling this CJS package with ori works okay\n // since the package doesn't require() any dependencies.\n // https://unpkg.com/browse/asap@2.0.6/\n packageSettings: {\n bundler: 'ori',\n },\n },\n },\n\n brotli: {\n '^1.0.0': {\n // index.js also imports a compress entry point with a reference to nonexistent Browser global\n // https://unpkg.com/browse/brotli@1.3.3/\n packageJson: {\n exports: {\n './decompress.js': './decompress.js',\n },\n },\n },\n },\n\n bson: {\n '^5.0.0 || ^6.0.0': {\n // Package conditionally references \"crypto\", causing an error even though it's never used.\n // Bundle with rollup instead, and ignore the warning about the empty crypto stub.\n packageSettings: {\n bundler: 'rollup',\n ignoredBundlerWarnings: ['Generated an empty chunk: \"_polyfill-node.crypto\"'],\n },\n },\n },\n\n 'gql.tada': {\n '^1.0.0': {\n // This package has a combination of browser and CLI code.\n // Remove the dependencies and entries which aren't needed in the browser.\n // https://unpkg.com/browse/gql.tada@1.8.10/\n packageSettings: {\n excludedDependencies: ['@0no-co/graphqlsp', '@gql.tada/cli-utils', '@gql.tada/internal', 'typescript'],\n },\n packageJson: {\n exports: './dist/gql-tada.mjs',\n },\n },\n },\n\n 'html-dom-parser': {\n '>=0 <6.0.0': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n 'html-react-parser': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n '>=0 <6.0.0': {\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n htmlparser2: {\n // Issue below starts in 8.0.1 and continues in 9\n '^8.0.1 || ^9.0.0': {\n // This has an additional ./lib/WritableStream exports map entry which uses node stream\n // https://unpkg.com/browse/htmlparser2@9.1.0/\n packageJson: {\n exports: './lib/esm/index.js',\n },\n },\n },\n\n react: {\n '^16.14.0 || ^17.0.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/react@17/package.json\n packageJson: {\n exports: {\n '.': './index.js',\n './jsx-runtime': './jsx-runtime.js',\n './jsx-dev-runtime': './jsx-dev-runtime.js',\n },\n },\n },\n },\n\n scheduler: {\n '>=0 <0.21.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/scheduler@0.20.x/package.json\n packageJson: {\n exports: {\n '.': './index.js',\n './tracing': './tracing.js',\n },\n },\n },\n '>=0.21.0 <1.0.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/scheduler@0.21.0/package.json\n packageJson: {\n exports: './index.js',\n },\n },\n },\n\n 'socket.io-client': {\n '^4.4.1': {\n // Remove unneeded exports\n // https://unpkg.com/browse/socket.io-client@4/package.json\n packageJson: {\n exports: './build/esm/index.js',\n },\n },\n },\n\n 'style-to-object': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n '>=0 <2.0.0': {\n // Package is\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n tslib: {\n '>=0 <2.5.3': {\n // Remove unneeded exports\n // https://unpkg.com/browse/tslib@2.5.2/package.json\n packageJson: {\n exports: './tslib.es6.js',\n },\n },\n '^2.5.3': {\n // Remove unneeded exports\n // https://unpkg.com/browse/tslib@2.5.3/package.json\n packageJson: {\n exports: './tslib.es6.mjs',\n },\n },\n },\n\n // Please add new entries in alphabetical order by name!\n});\n"]}
|
|
1
|
+
{"version":3,"file":"builtInSettings.js","sourceRoot":"","sources":["../../src/builtInSettings/builtInSettings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAMvC;IACA,iBAAiB,EAAE;QACjB,YAAY,EAAE;YACZ,uDAAuD;YACvD,eAAe,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;SACvC;KACF;IACD,0BAA0B,EAAE;QAC1B,YAAY,EAAE;YACZ,kCAAkC;YAClC,eAAe,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;SACvC;KACF;IACD,2BAA2B,EAAE;QAC3B,YAAY,EAAE;YACZ,kCAAkC;YAClC,eAAe,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;SACvC;KACF;IACD,8BAA8B,EAAE;QAC9B,YAAY,EAAE;YACZ,gEAAgE;YAChE,eAAe,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;SACvC;KACF;IAED,gCAAg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D,WAAW,EAAE;gBACX,OAAO,EAAE,sBAAsB;aAChC;SACF;KACF;IAED,iBAAiB,EAAE;QACjB,wCAAwC;QACxC,6EAA6E;QAC7E,wGAAwG;QACxG,oCAAoC;QACpC,YAAY,EAAE;YACZ,aAAa;YACb,eAAe,EAAE;gBACf,OAAO,EAAE,QAAQ;aAClB;SACF;KACF;IAED,KAAK,EAAE;QACL,YAAY,EAAE;YACZ,0BAA0B;YAC1B,oDAAoD;YACpD,WAAW,EAAE;gBACX,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,QAAQ,EAAE;YACR,0BAA0B;YAC1B,oDAAoD;YACpD,WAAW,EAAE;gBACX,OAAO,EAAE,iBAAiB;aAC3B;SACF;KACF;IAED,wDAAwD;CACzD,CAAC,CAAC","sourcesContent":["import type { PackageJson, PackageSettings } from '@ms-cloudpack/common-types';\nimport { deepFreeze } from './deepFreeze.js';\n\nexport interface BuiltInSettings {\n /**\n * Package settings to automatically apply for this package name/version.\n * (These are merged by `getPackageSettings`, mostly as called by `createPackageSettingsTransform`.)\n */\n packageSettings?: Omit<PackageSettings, 'match' | 'exports'>;\n /**\n * package.json settings to automatically apply for this package name/version.\n * These **overwrite** original properties of the `package.json` and are applied by\n * `PackageDefinitions` using `createBuiltInSettingsTransform`.\n */\n packageJson?: Omit<PackageJson, 'name' | 'version' | 'cloudpack'>;\n}\n\n/**\n * Mapping from package name to version range to built-in settings.\n *\n * This object is frozen to prevent accidental modification.\n *\n * The reason we're handling package.json modifications (just `exports` as of writing) and\n * `PackageSettings` separately is mainly to get around issues with merging exports maps.\n * https://github.com/microsoft/cloudpack/pull/2452#discussion_r1835192676\n * (If the exports merging issue is fixed in the future, and we don't find any cases where we want\n * to override other package.json properties, they could potentially be combined and handled with\n * only package settings.)\n */\nexport const builtInSettings = deepFreeze<\n Partial<{\n [packageName: string]: {\n [versionRange: string]: BuiltInSettings;\n };\n }>\n>({\n '@fluentai/flair': {\n '>=0 <1.0.0': {\n // Use rollup as esbuild translates classes incorrectly\n packageSettings: { bundler: 'rollup' },\n },\n },\n '@fluentui/react-bindings': {\n '>=0 <1.0.0': {\n // Use rollup to preserve export *\n packageSettings: { bundler: 'rollup' },\n },\n },\n '@fluentui/react-northstar': {\n '>=0 <1.0.0': {\n // Use rollup to preserve export *\n packageSettings: { bundler: 'rollup' },\n },\n },\n '@fluid-internal/client-utils': {\n '>=0 <3.0.0': {\n // This package mixes CJS and ESM which causes problems for ori.\n packageSettings: { bundler: 'rollup' },\n },\n },\n\n '@microsoft/objectstoreprovider': {\n '>=0 <1.0.0': {\n // It is a CJS package with a declared side effect, we need webpack/rspack to respect it.\n packageSettings: {\n bundler: 'rspack',\n },\n },\n },\n\n '@microsoft/recognizers-text-date-time': {\n '^1.0.0': {\n // This has a \"browser\" entry which doesn't provide exports correctly in the browser when bundled??\n // Switching to the regular entry point makes it work.\n // https://unpkg.com/browse/@microsoft/recognizers-text-date-time@1.3.2/\n packageJson: {\n exports: './dist/recognizers-text-date-time.es5.js',\n },\n },\n },\n\n asap: {\n '^2.0.0': {\n // This package has different browser and non-browser versions in the \"browser\" field.\n // Trying to bundle it with rollup (which creates an ESM stub) gives this error:\n // [ESM stub generation] /<repo path>/node_modules/asap/browser-asap.js:10:33\n // Error creating stub for entry \"./browser-asap\":\n // TypeError: rawAsap.makeRequestCallFromTimer is not a function\n // It's not clear why this happens, but bundling this CJS package with ori works okay\n // since the package doesn't require() any dependencies.\n // https://unpkg.com/browse/asap@2.0.6/\n packageSettings: {\n bundler: 'ori',\n },\n },\n },\n\n brotli: {\n '^1.0.0': {\n // index.js also imports a compress entry point with a reference to nonexistent Browser global\n // https://unpkg.com/browse/brotli@1.3.3/\n packageJson: {\n exports: {\n './decompress.js': './decompress.js',\n },\n },\n },\n },\n\n bson: {\n '^5.0.0 || ^6.0.0': {\n // Package conditionally references \"crypto\", causing an error even though it's never used.\n // Bundle with rollup instead, and ignore the warning about the empty crypto stub.\n packageSettings: {\n bundler: 'rollup',\n ignoredBundlerWarnings: ['Generated an empty chunk: \"_polyfill-node.crypto\"'],\n },\n },\n },\n\n color: {\n '>=0 <6.0.0': {\n packageSettings: {\n // This package iterates through the keys of \"color-convert\" and errors on a default key.\n // It is a small package so we can inline all its dependencies and use ori instead of rollup.\n inlinedDependencies: ['color-convert', 'color-string'],\n excludedDependencies: ['color-convert', 'color-string'],\n bundler: 'ori',\n },\n },\n },\n\n 'gql.tada': {\n '^1.0.0': {\n // This package has a combination of browser and CLI code.\n // Remove the dependencies and entries which aren't needed in the browser.\n // https://unpkg.com/browse/gql.tada@1.8.10/\n packageSettings: {\n excludedDependencies: ['@0no-co/graphqlsp', '@gql.tada/cli-utils', '@gql.tada/internal', 'typescript'],\n },\n packageJson: {\n exports: './dist/gql-tada.mjs',\n },\n },\n },\n\n 'html-dom-parser': {\n '>=0 <6.0.0': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n 'html-react-parser': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n '>=0 <6.0.0': {\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n htmlparser2: {\n // Issue below starts in 8.0.1 and continues in 9\n '^8.0.1 || ^9.0.0': {\n // This has an additional ./lib/WritableStream exports map entry which uses node stream\n // https://unpkg.com/browse/htmlparser2@9.1.0/\n packageJson: {\n exports: './lib/esm/index.js',\n },\n },\n },\n\n 'office-ui-fabric-react': {\n '>=0 <8.0.0': {\n // Use rollup to preserve export *\n packageSettings: { bundler: 'rollup' },\n },\n },\n\n postcss: {\n // The package added a .mjs as a stub. This confuses cloudpack and we try to bundle with ori and fail\n '^8.0.0': {\n packageJson: {\n exports: './lib/postcss.js',\n },\n },\n },\n\n react: {\n '^16.14.0 || ^17.0.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/react@17/package.json\n packageJson: {\n exports: {\n '.': './index.js',\n './jsx-runtime': './jsx-runtime.js',\n './jsx-dev-runtime': './jsx-dev-runtime.js',\n },\n },\n },\n },\n\n scheduler: {\n '>=0 <0.21.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/scheduler@0.20.x/package.json\n packageJson: {\n exports: {\n '.': './index.js',\n './tracing': './tracing.js',\n },\n },\n },\n '>=0.21.0 <1.0.0': {\n // Package is missing an exports map\n // https://unpkg.com/browse/scheduler@0.21.0/package.json\n packageJson: {\n exports: './index.js',\n },\n },\n },\n\n 'socket.io-client': {\n '^4.4.1': {\n // Remove unneeded exports\n // https://unpkg.com/browse/socket.io-client@4/package.json\n packageJson: {\n exports: './build/esm/index.js',\n },\n },\n },\n\n 'style-to-object': {\n // Old versions of this package are CJS,\n // and newer versions have an ESM entry that imports CJS code with `require`.\n // This causes the runtime issue \"Dynamic require of {package} is not supported\" when bundling with ori,\n // so we need to use rollup instead.\n '>=0 <2.0.0': {\n // Package is\n packageSettings: {\n bundler: 'rollup',\n },\n },\n },\n\n tslib: {\n '>=0 <2.5.3': {\n // Remove unneeded exports\n // https://unpkg.com/browse/tslib@2.5.2/package.json\n packageJson: {\n exports: './tslib.es6.js',\n },\n },\n '^2.5.3': {\n // Remove unneeded exports\n // https://unpkg.com/browse/tslib@2.5.3/package.json\n packageJson: {\n exports: './tslib.es6.mjs',\n },\n },\n },\n\n // Please add new entries in alphabetical order by name!\n});\n"]}
|
|
@@ -26,6 +26,16 @@ export interface ReadAppConfigOptions {
|
|
|
26
26
|
*/
|
|
27
27
|
configFileName?: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Application configuration combined with the file paths that were used to load it.
|
|
31
|
+
*/
|
|
32
|
+
export interface AppConfigWithPaths {
|
|
33
|
+
appConfig: AppConfig;
|
|
34
|
+
/**
|
|
35
|
+
* The paths to the config files that were read, in order of precedence.
|
|
36
|
+
*/
|
|
37
|
+
appConfigPaths: string[];
|
|
38
|
+
}
|
|
29
39
|
/**
|
|
30
40
|
* Reads the user config file and merges with any parent configs asynchronously.
|
|
31
41
|
* Note this is only useful for making modifications to the user config.
|
|
@@ -35,5 +45,5 @@ export interface ReadAppConfigOptions {
|
|
|
35
45
|
* or any settings are invalid. (As of writing, this doesn't do full schema validation; it only
|
|
36
46
|
* checks certain specific settings.)
|
|
37
47
|
*/
|
|
38
|
-
export declare function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<
|
|
48
|
+
export declare function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<AppConfigWithPaths>;
|
|
39
49
|
//# sourceMappingURL=readAppConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAe,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAElH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAatE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,oBAAoB,CAAC,EAAE,eAAe,EAAE,CAAC;IAEzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAE/B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,iBAAiB,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAEtD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAe,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAElH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAatE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,oBAAoB,CAAC,EAAE,eAAe,EAAE,CAAC;IAEzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAE/B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,iBAAiB,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;IAEtD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,SAAS,CAAC;IAErB;;OAEG;IACH,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4ChH"}
|
|
@@ -35,7 +35,7 @@ export async function readAppConfig(appPath, options) {
|
|
|
35
35
|
throw new Error(`Config file not found: ${options.configFileName}`);
|
|
36
36
|
}
|
|
37
37
|
// This is fine, use an empty config
|
|
38
|
-
config = {};
|
|
38
|
+
config = { appConfig: {}, appConfigPaths: [] };
|
|
39
39
|
}
|
|
40
40
|
else if (path.extname(appConfigPath) === '.json') {
|
|
41
41
|
// Check for an existing JSON app config first
|
|
@@ -45,10 +45,18 @@ export async function readAppConfig(appPath, options) {
|
|
|
45
45
|
// Otherwise, read as a JS file
|
|
46
46
|
config = await readJsAppConfig(appConfigPath);
|
|
47
47
|
}
|
|
48
|
-
expandEnvironmentVariables(config);
|
|
48
|
+
expandEnvironmentVariables(config.appConfig);
|
|
49
49
|
// Merge extra settings (usually from CLI options) into the final config.
|
|
50
50
|
if (options) {
|
|
51
|
-
config = augmentAppConfig(config, options);
|
|
51
|
+
config.appConfig = augmentAppConfig(config.appConfig, options);
|
|
52
|
+
}
|
|
53
|
+
if (appConfigPath) {
|
|
54
|
+
if (config.appConfigPaths) {
|
|
55
|
+
config.appConfigPaths?.unshift(appConfigPath); // Add the config path to the beginning of the list
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
config.appConfigPaths = [appConfigPath]; // If no paths were set, just use the current one
|
|
59
|
+
}
|
|
52
60
|
}
|
|
53
61
|
return config;
|
|
54
62
|
}
|
|
@@ -116,16 +124,21 @@ async function processConfig(configPath, appConfig) {
|
|
|
116
124
|
checkFeatures(appConfig.features, configPath);
|
|
117
125
|
resolveBundlerCapabilities({ appConfig, configPath });
|
|
118
126
|
processDeprecatedValues(appConfig);
|
|
127
|
+
const configPaths = [];
|
|
119
128
|
// Read and merge with any parent configs (the same processing is applied to parent configs)
|
|
120
129
|
const { extends: _extends = [] } = appConfig;
|
|
121
130
|
const extendsArray = Array.isArray(_extends) ? _extends : [_extends];
|
|
122
|
-
const
|
|
131
|
+
const parentResults = await Promise.all(extendsArray.map(async (importSpecifier) => {
|
|
123
132
|
const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });
|
|
124
|
-
|
|
125
|
-
? readJsonAppConfig(parentConfigPath)
|
|
126
|
-
: readJsAppConfig(parentConfigPath);
|
|
133
|
+
const result = path.extname(parentConfigPath).toLowerCase() === '.json'
|
|
134
|
+
? await readJsonAppConfig(parentConfigPath)
|
|
135
|
+
: await readJsAppConfig(parentConfigPath);
|
|
136
|
+
// Collect paths from parent configs
|
|
137
|
+
configPaths.push(...result.appConfigPaths);
|
|
138
|
+
return result.appConfig;
|
|
127
139
|
}));
|
|
128
|
-
|
|
140
|
+
const mergedConfig = mergeParentConfig({ appConfig, parentConfigs: parentResults });
|
|
141
|
+
return { appConfig: mergedConfig, appConfigPaths: configPaths };
|
|
129
142
|
}
|
|
130
143
|
/**
|
|
131
144
|
* Validate parts of the current config file (before merging with parents) and log any errors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAkCzD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,OAA8B;IACjF,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAE3E,IAAI,MAAiB,CAAC;IAEtB,sCAAsC;IACtC,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,IAAI,aAAa,CA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AAI,SAAS,EAAE,CAAC;QACd,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,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;IACD,qCAAqC;AACvC,CAAC","sourcesContent":["import type { AppConfig, FeatureName, Features, PackageSettings, ServerConfig } from '@ms-cloudpack/common-types';\nimport { allFeatures } from '@ms-cloudpack/common-types';\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { augmentAppConfig } from './augmentAppConfig.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra feature settings. There will be a warning if any of these are invalid.\n */\n extraFeatures?: Features;\n\n /**\n * Extra package settings to add at the end of user-provided settings (so they take precedence).\n */\n extraPackageSettings?: PackageSettings[];\n\n /**\n * Extra define flags to add at the end of user-provided settings (so they take precedence).\n */\n extraDefineFlags?: DefineFlags;\n\n /**\n * Enable default features that are not explicitly set in the config.\n */\n enableDefaultFeatures?: boolean;\n\n /**\n * Overrides for the server config.\n */\n extraServerConfig?: Pick<ServerConfig, 'showOverlay'>;\n\n /**\n * Custom config file name to use instead of cloudpack.config.json\n */\n configFileName?: string;\n}\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, there's some error reading it,\n * or any settings are invalid. (As of writing, this doesn't do full schema validation; it only\n * checks certain specific settings.)\n */\nexport async function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<AppConfig> {\n const { appConfigPaths } = getConfigPath(appPath, options?.configFileName);\n\n let config: AppConfig;\n\n // Check for JS and JSON config files.\n const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));\n if (existingPaths.length > 1) {\n const message = 'Multiple Cloudpack config files found. Determine the correct one and delete the others:';\n throw new Error([message, ...existingPaths].join('\\n '));\n }\n\n const appConfigPath = existingPaths[0];\n if (!appConfigPath) {\n // If a custom config was specified, it must exist\n if (options?.configFileName) {\n throw new Error(`Config file not found: ${options.configFileName}`);\n }\n // This is fine, use an empty config\n config = {};\n } else if (path.extname(appConfigPath) === '.json') {\n // Check for an existing JSON app config first\n config = await readJsonAppConfig(appConfigPath);\n } else {\n // Otherwise, read as a JS file\n config = await readJsAppConfig(appConfigPath);\n }\n\n expandEnvironmentVariables(config as Record<string, unknown>);\n\n // Merge extra settings (usually from CLI options) into the final config.\n if (options) {\n config = augmentAppConfig(config, options);\n }\n\n return config;\n}\n\n/**\n * Resolve import specifiers for bundler capabilities registry.\n * Throws if a specifier can't be resolved.\n */\nfunction resolveBundlerCapabilities(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { bundlerCapabilitiesRegistry },\n configPath,\n } = params;\n if (!bundlerCapabilitiesRegistry) {\n return;\n }\n\n for (const [name, importSpecifier] of Object.entries(bundlerCapabilitiesRegistry)) {\n try {\n const moduleUrl = resolveModule({ parentPath: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl.toString();\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\n }\n }\n}\n\n/**\n * Reads the JSON app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsonAppConfig(configPath: string): Promise<AppConfig> {\n const appConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!appConfig) {\n // shouldn't happen, but just in case/to satisfy the types...\n throw new Error(`Cloudpack config not found at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n}\n\n/**\n * Reads the JavaScript app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsAppConfig(configPath: string): Promise<AppConfig> {\n // Convert configPath to a URL for import.\n try {\n const appConfig = (await (import(pathToFileURL(configPath).toString()) as Promise<{ default?: AppConfig }>))\n .default;\n if (!appConfig) {\n throw new Error(`Missing default export from Cloudpack config at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n } catch (e) {\n throw new Error(`Error reading config file ${configPath}:\\n${(e as Error).message || e}`);\n }\n}\n\n/**\n * Processes the app config file and merges it with any parent configs.\n * This includes validating the config, checking for deprecated values, and resolving bundler capabilities.\n */\nasync function processConfig(configPath: string, appConfig: AppConfig): Promise<AppConfig> {\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n checkFeatures(appConfig.features, configPath);\n\n resolveBundlerCapabilities({ appConfig, configPath });\n\n processDeprecatedValues(appConfig);\n\n // Read and merge with any parent configs (the same processing is applied to parent configs)\n const { extends: _extends = [] } = appConfig;\n const extendsArray = Array.isArray(_extends) ? _extends : [_extends];\n const parentConfigs = await Promise.all(\n extendsArray.map((importSpecifier) => {\n const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });\n return path.extname(parentConfigPath).toLowerCase() === '.json'\n ? readJsonAppConfig(parentConfigPath)\n : readJsAppConfig(parentConfigPath);\n }),\n );\n return mergeParentConfig({ appConfig, parentConfigs });\n}\n\n/**\n * Validate parts of the current config file (before merging with parents) and log any errors.\n * Logging here and then letting the caller throw if needed allows us to show more errors at once.\n * @returns true if valid, false if not\n */\nfunction validateConfig(appConfig: AppConfig): boolean {\n let isValid = true;\n\n // Verify that there are no matches with a negated name and a version\n for (const setting of appConfig.packageSettings || []) {\n const { match } = setting;\n const matches = Array.isArray(match) ? match : [match];\n for (const m of matches) {\n const result = validateMatch(m);\n if (!result.isValid) {\n isValid = false;\n console.error(`Invalid packageSettings match: ${result.error}`);\n }\n }\n }\n\n return isValid;\n}\n\n/**\n * Warn if any feature names are invalid, and remove them.\n */\nfunction checkFeatures(features: Record<string, boolean> | undefined, configPath: string): void {\n if (!features) {\n return;\n }\n\n const invalidFeatures: string[] = [];\n for (const featureName of Object.keys(features)) {\n if (!allFeatures[featureName as FeatureName]) {\n invalidFeatures.push(featureName);\n delete features[featureName];\n }\n }\n\n if (invalidFeatures.length) {\n console.warn(\n `Unknown feature(s) found in ${configPath} (most likely they were graduated or removed in Cloudpack):\\n ` +\n invalidFeatures.join(', '),\n );\n }\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig): void {\n /* eslint-disable etc/no-deprecated */\n const { devServer, server, packageSettings = [] } = config;\n\n if (devServer) {\n if (server) {\n throw new Error('Cannot have both \"devServer\" and \"server\" in the config file. Use \"server\" only.');\n }\n\n config.server = devServer;\n delete config.devServer;\n }\n\n if (server?.routes) {\n config.routes = server.routes;\n delete server.routes;\n }\n\n for (const setting of packageSettings) {\n if (setting.bundlerType) {\n setting.bundler = setting.bundlerType;\n delete setting.bundlerType;\n }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AAW,CAAC,WAA0B,CAAC,EAAE,CAAC;YAC7C,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAClC,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,IAAI,CACV,+BAA+B,UAAU,iEAAiE;YACxG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,MAAiB;IAChD,sCAAsC;IACtC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAE3D,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,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;IACD,qCAAqC;AACvC,CAAC","sourcesContent":["import type { AppConfig, FeatureName, Features, PackageSettings, ServerConfig } from '@ms-cloudpack/common-types';\nimport { allFeatures } from '@ms-cloudpack/common-types';\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { augmentAppConfig } from './augmentAppConfig.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra feature settings. There will be a warning if any of these are invalid.\n */\n extraFeatures?: Features;\n\n /**\n * Extra package settings to add at the end of user-provided settings (so they take precedence).\n */\n extraPackageSettings?: PackageSettings[];\n\n /**\n * Extra define flags to add at the end of user-provided settings (so they take precedence).\n */\n extraDefineFlags?: DefineFlags;\n\n /**\n * Enable default features that are not explicitly set in the config.\n */\n enableDefaultFeatures?: boolean;\n\n /**\n * Overrides for the server config.\n */\n extraServerConfig?: Pick<ServerConfig, 'showOverlay'>;\n\n /**\n * Custom config file name to use instead of cloudpack.config.json\n */\n configFileName?: string;\n}\n\n/**\n * Application configuration combined with the file paths that were used to load it.\n */\nexport interface AppConfigWithPaths {\n appConfig: AppConfig;\n\n /**\n * The paths to the config files that were read, in order of precedence.\n */\n appConfigPaths: string[];\n}\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, there's some error reading it,\n * or any settings are invalid. (As of writing, this doesn't do full schema validation; it only\n * checks certain specific settings.)\n */\nexport async function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<AppConfigWithPaths> {\n const { appConfigPaths } = getConfigPath(appPath, options?.configFileName);\n\n let config: AppConfigWithPaths;\n\n // Check for JS and JSON config files.\n const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));\n if (existingPaths.length > 1) {\n const message = 'Multiple Cloudpack config files found. Determine the correct one and delete the others:';\n throw new Error([message, ...existingPaths].join('\\n '));\n }\n\n const appConfigPath = existingPaths[0];\n if (!appConfigPath) {\n // If a custom config was specified, it must exist\n if (options?.configFileName) {\n throw new Error(`Config file not found: ${options.configFileName}`);\n }\n // This is fine, use an empty config\n config = { appConfig: {}, appConfigPaths: [] };\n } else if (path.extname(appConfigPath) === '.json') {\n // Check for an existing JSON app config first\n config = await readJsonAppConfig(appConfigPath);\n } else {\n // Otherwise, read as a JS file\n config = await readJsAppConfig(appConfigPath);\n }\n\n expandEnvironmentVariables(config.appConfig as Record<string, unknown>);\n\n // Merge extra settings (usually from CLI options) into the final config.\n if (options) {\n config.appConfig = augmentAppConfig(config.appConfig, options);\n }\n\n if (appConfigPath) {\n if (config.appConfigPaths) {\n config.appConfigPaths?.unshift(appConfigPath); // Add the config path to the beginning of the list\n } else {\n config.appConfigPaths = [appConfigPath]; // If no paths were set, just use the current one\n }\n }\n\n return config;\n}\n\n/**\n * Resolve import specifiers for bundler capabilities registry.\n * Throws if a specifier can't be resolved.\n */\nfunction resolveBundlerCapabilities(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { bundlerCapabilitiesRegistry },\n configPath,\n } = params;\n if (!bundlerCapabilitiesRegistry) {\n return;\n }\n\n for (const [name, importSpecifier] of Object.entries(bundlerCapabilitiesRegistry)) {\n try {\n const moduleUrl = resolveModule({ parentPath: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl.toString();\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\n }\n }\n}\n\n/**\n * Reads the JSON app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsonAppConfig(configPath: string): Promise<AppConfigWithPaths> {\n const appConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!appConfig) {\n // shouldn't happen, but just in case/to satisfy the types...\n throw new Error(`Cloudpack config not found at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n}\n\n/**\n * Reads the JavaScript app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsAppConfig(configPath: string): Promise<AppConfigWithPaths> {\n // Convert configPath to a URL for import.\n try {\n const appConfig = (await (import(pathToFileURL(configPath).toString()) as Promise<{ default?: AppConfig }>))\n .default;\n if (!appConfig) {\n throw new Error(`Missing default export from Cloudpack config at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n } catch (e) {\n throw new Error(`Error reading config file ${configPath}:\\n${(e as Error).message || e}`);\n }\n}\n\n/**\n * Processes the app config file and merges it with any parent configs.\n * This includes validating the config, checking for deprecated values, and resolving bundler capabilities.\n */\nasync function processConfig(configPath: string, appConfig: AppConfig): Promise<AppConfigWithPaths> {\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n checkFeatures(appConfig.features, configPath);\n\n resolveBundlerCapabilities({ appConfig, configPath });\n\n processDeprecatedValues(appConfig);\n\n const configPaths: string[] = [];\n\n // Read and merge with any parent configs (the same processing is applied to parent configs)\n const { extends: _extends = [] } = appConfig;\n const extendsArray = Array.isArray(_extends) ? _extends : [_extends];\n const parentResults = await Promise.all(\n extendsArray.map(async (importSpecifier) => {\n const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });\n\n const result =\n path.extname(parentConfigPath).toLowerCase() === '.json'\n ? await readJsonAppConfig(parentConfigPath)\n : await readJsAppConfig(parentConfigPath);\n\n // Collect paths from parent configs\n configPaths.push(...result.appConfigPaths);\n return result.appConfig;\n }),\n );\n\n const mergedConfig = mergeParentConfig({ appConfig, parentConfigs: parentResults });\n return { appConfig: mergedConfig, appConfigPaths: configPaths };\n}\n\n/**\n * Validate parts of the current config file (before merging with parents) and log any errors.\n * Logging here and then letting the caller throw if needed allows us to show more errors at once.\n * @returns true if valid, false if not\n */\nfunction validateConfig(appConfig: AppConfig): boolean {\n let isValid = true;\n\n // Verify that there are no matches with a negated name and a version\n for (const setting of appConfig.packageSettings || []) {\n const { match } = setting;\n const matches = Array.isArray(match) ? match : [match];\n for (const m of matches) {\n const result = validateMatch(m);\n if (!result.isValid) {\n isValid = false;\n console.error(`Invalid packageSettings match: ${result.error}`);\n }\n }\n }\n\n return isValid;\n}\n\n/**\n * Warn if any feature names are invalid, and remove them.\n */\nfunction checkFeatures(features: Record<string, boolean> | undefined, configPath: string): void {\n if (!features) {\n return;\n }\n\n const invalidFeatures: string[] = [];\n for (const featureName of Object.keys(features)) {\n if (!allFeatures[featureName as FeatureName]) {\n invalidFeatures.push(featureName);\n delete features[featureName];\n }\n }\n\n if (invalidFeatures.length) {\n console.warn(\n `Unknown feature(s) found in ${configPath} (most likely they were graduated or removed in Cloudpack):\\n ` +\n invalidFeatures.join(', '),\n );\n }\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig): void {\n /* eslint-disable etc/no-deprecated */\n const { devServer, server, packageSettings = [] } = config;\n\n if (devServer) {\n if (server) {\n throw new Error('Cannot have both \"devServer\" and \"server\" in the config file. Use \"server\" only.');\n }\n\n config.server = devServer;\n delete config.devServer;\n }\n\n if (server?.routes) {\n config.routes = server.routes;\n delete server.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 /* eslint-enable etc/no-deprecated */\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc9E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAClD,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG;IACzD,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEJ;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc9E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAClD,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG;IACzD,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEJ;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAmCvG"}
|
|
@@ -14,14 +14,20 @@ import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
|
|
|
14
14
|
*/
|
|
15
15
|
export async function readConfig(appPath, options) {
|
|
16
16
|
const { mode = 'library', logBundleInfo, configFileName, ...appConfigOptions } = options || {};
|
|
17
|
-
const { routes, ...appConfig } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });
|
|
17
|
+
const { appConfig: { routes, ...appConfig }, appConfigPaths, } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });
|
|
18
18
|
const generatedConfig = await readGeneratedConfig(appPath);
|
|
19
|
+
const { getConfigPath } = await import('../getConfigPath.js');
|
|
20
|
+
const { generatedConfigPath } = getConfigPath(appPath);
|
|
19
21
|
const config = {
|
|
20
22
|
...appConfig,
|
|
21
23
|
appPath,
|
|
22
24
|
mode,
|
|
23
25
|
generated: generatedConfig,
|
|
24
26
|
generatedSnapshot: cloneJson(generatedConfig),
|
|
27
|
+
configPaths: {
|
|
28
|
+
generatedConfigPath,
|
|
29
|
+
appConfigPaths,
|
|
30
|
+
},
|
|
25
31
|
};
|
|
26
32
|
if (logBundleInfo) {
|
|
27
33
|
// Only set this if true, mainly to avoid interfering with tests.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAC9E,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,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAc1E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,OAA2B;IAC3E,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE/F,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,EAAE,GAAG,gBAAgB,EAAE,cAAc,EAAE,CAAC,CAAC;IACvG,MAAM,eAAe,GAAG,MAAM,mB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wB,CAAC,UAAU,CAAC;KAClG,CAAC;AACJ,CAAC","sourcesContent":["import type {\n BootstrapRoute,\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, type ReadAppConfigOptions } 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 { cloneJson, 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\nexport type ReadConfigOptions = ReadAppConfigOptions &\n Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>> & {\n /** Custom config file name to use instead of cloudpack.config.json */\n configFileName?: string;\n };\n\n/**\n * Read the app config and generated config if they exist.\n *\n * Throws if there's an error reading a file or certain settings are invalid. (As of writing,\n * this doesn't do full schema validation; it only validates certain specific settings.)\n */\nexport async function readConfig(appPath: string, options?: ReadConfigOptions): Promise<CloudpackConfig> {\n const { mode = 'library', logBundleInfo, configFileName, ...appConfigOptions } = options || {};\n\n const { routes, ...appConfig } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });\n const generatedConfig = await readGeneratedConfig(appPath);\n\n const config: CloudpackConfig = {\n ...appConfig,\n appPath,\n mode,\n generated: generatedConfig,\n generatedSnapshot: cloneJson(generatedConfig),\n };\n\n if (logBundleInfo) {\n // Only set this if true, mainly to avoid interfering with tests.\n config.logBundleInfo = true;\n }\n\n // Expands all routes which refer to source files into fully transformed route objects.\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, serverEntry, ...rest } = route as ShorthandRenderedRoute;\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 (serverEntry) {\n // eslint-disable-next-line etc/no-deprecated\n if (renderedRoute.renderScript) {\n throw new Error(\n // eslint-disable-next-line etc/no-deprecated\n `A route cannot have both serverEntry (\"${serverEntry}\") and renderScript (\"${renderedRoute.renderScript}\").`,\n );\n }\n\n renderedRoute.serverEntry = expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[serverEntry] ? serverEntry : undefined,\n filePath: flattenedExports[serverEntry] || serverEntry,\n entryType: 'serverEntry',\n appPath,\n });\n }\n\n if (exportEntry) {\n // Handle backwards compatibility with moving from exportEntry to entry.\n const filePath = flattenedExports[exportEntry];\n\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\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: {\n importPath: string | undefined;\n filePath: string;\n appPath: string;\n entryType?: 'entry' | 'serverEntry';\n}): ExpandedSourcePath {\n const { filePath, appPath, importPath, entryType = 'entry' } = options;\n const sourcePath = intermediateToSourcePath(filePath, appPath);\n\n if (!sourcePath) {\n throw new Error(`Could not resolve source path for ${entryType}: ${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
|
+
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MA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AA6F;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,OAKzB;IACC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IACvE,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,qCAAqC,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC;IACjF,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 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, type ReadAppConfigOptions } 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 { cloneJson, 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\nexport type ReadConfigOptions = ReadAppConfigOptions &\n Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>> & {\n /** Custom config file name to use instead of cloudpack.config.json */\n configFileName?: string;\n };\n\n/**\n * Read the app config and generated config if they exist.\n *\n * Throws if there's an error reading a file or certain settings are invalid. (As of writing,\n * this doesn't do full schema validation; it only validates certain specific settings.)\n */\nexport async function readConfig(appPath: string, options?: ReadConfigOptions): Promise<CloudpackConfig> {\n const { mode = 'library', logBundleInfo, configFileName, ...appConfigOptions } = options || {};\n\n const {\n appConfig: { routes, ...appConfig },\n appConfigPaths,\n } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });\n const generatedConfig = await readGeneratedConfig(appPath);\n\n const { getConfigPath } = await import('../getConfigPath.js');\n const { generatedConfigPath } = getConfigPath(appPath);\n\n const config: CloudpackConfig = {\n ...appConfig,\n appPath,\n mode,\n generated: generatedConfig,\n generatedSnapshot: cloneJson(generatedConfig),\n configPaths: {\n generatedConfigPath,\n appConfigPaths,\n },\n };\n\n if (logBundleInfo) {\n // Only set this if true, mainly to avoid interfering with tests.\n config.logBundleInfo = true;\n }\n\n // Expands all routes which refer to source files into fully transformed route objects.\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, serverEntry, ...rest } = route as ShorthandRenderedRoute;\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 (serverEntry) {\n // eslint-disable-next-line etc/no-deprecated\n if (renderedRoute.renderScript) {\n throw new Error(\n // eslint-disable-next-line etc/no-deprecated\n `A route cannot have both serverEntry (\"${serverEntry}\") and renderScript (\"${renderedRoute.renderScript}\").`,\n );\n }\n\n renderedRoute.serverEntry = expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[serverEntry] ? serverEntry : undefined,\n filePath: flattenedExports[serverEntry] || serverEntry,\n entryType: 'serverEntry',\n appPath,\n });\n }\n\n if (exportEntry) {\n // Handle backwards compatibility with moving from exportEntry to entry.\n const filePath = flattenedExports[exportEntry];\n\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\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: {\n importPath: string | undefined;\n filePath: string;\n appPath: string;\n entryType?: 'entry' | 'serverEntry';\n}): ExpandedSourcePath {\n const { filePath, appPath, importPath, entryType = 'entry' } = options;\n const sourcePath = intermediateToSourcePath(filePath, appPath);\n\n if (!sourcePath) {\n throw new Error(`Could not resolve source path for ${entryType}: ${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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/config",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.4",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.27.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.27.7",
|
|
18
18
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.11",
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^12.5.
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^12.5.1",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
22
|
-
"@ms-cloudpack/path-utilities": "^3.1.
|
|
22
|
+
"@ms-cloudpack/path-utilities": "^3.1.22",
|
|
23
23
|
"semver": "^7.6.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|