polen 0.8.0-next.7 → 0.8.0-next.9
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/build/api/api.d.ts +4 -0
- package/build/api/api.d.ts.map +1 -0
- package/build/api/api.js +4 -0
- package/build/api/api.js.map +1 -0
- package/build/api/{build/build.d.ts → builder/builder.d.ts} +3 -3
- package/build/api/builder/builder.d.ts.map +1 -0
- package/build/api/{build/build.js → builder/builder.js} +11 -14
- package/build/api/builder/builder.js.map +1 -0
- package/build/api/builder/index.d.ts +2 -0
- package/build/api/builder/index.d.ts.map +1 -0
- package/build/api/builder/index.js +2 -0
- package/build/api/builder/index.js.map +1 -0
- package/build/api/config/config.d.ts +5 -0
- package/build/api/config/config.d.ts.map +1 -0
- package/build/api/config/config.js +5 -0
- package/build/api/config/config.js.map +1 -0
- package/build/api/{configurator → config}/configurator.d.ts +13 -3
- package/build/api/config/configurator.d.ts.map +1 -0
- package/build/api/{configurator → config}/configurator.js +52 -28
- package/build/api/config/configurator.js.map +1 -0
- package/build/api/config/define.d.ts +7 -0
- package/build/api/config/define.d.ts.map +1 -0
- package/build/api/config/define.js +7 -0
- package/build/api/config/define.js.map +1 -0
- package/build/api/config/index.d.ts +2 -0
- package/build/api/config/index.d.ts.map +1 -0
- package/build/api/config/index.js +2 -0
- package/build/api/config/index.js.map +1 -0
- package/build/api/config/load.d.ts +11 -0
- package/build/api/config/load.d.ts.map +1 -0
- package/build/api/config/load.js +36 -0
- package/build/api/config/load.js.map +1 -0
- package/build/api/config/merge.d.ts +7 -0
- package/build/api/config/merge.d.ts.map +1 -0
- package/build/api/config/merge.js +54 -0
- package/build/api/config/merge.js.map +1 -0
- package/build/api/config-resolver/config-resolver.d.ts +3 -0
- package/build/api/config-resolver/config-resolver.d.ts.map +1 -0
- package/build/api/config-resolver/config-resolver.js +3 -0
- package/build/api/config-resolver/config-resolver.js.map +1 -0
- package/build/api/config-resolver/index.d.ts +2 -0
- package/build/api/config-resolver/index.d.ts.map +1 -0
- package/build/api/config-resolver/index.js +2 -0
- package/build/api/config-resolver/index.js.map +1 -0
- package/build/api/config-resolver/resolve.d.ts +16 -0
- package/build/api/config-resolver/resolve.d.ts.map +1 -0
- package/build/api/config-resolver/resolve.js +21 -0
- package/build/api/config-resolver/resolve.js.map +1 -0
- package/build/api/config-resolver/vite.d.ts +10 -0
- package/build/api/config-resolver/vite.d.ts.map +1 -0
- package/build/api/config-resolver/vite.js +18 -0
- package/build/api/config-resolver/vite.js.map +1 -0
- package/build/api/index.d.ts +2 -0
- package/build/api/index.d.ts.map +1 -0
- package/build/api/index.js +2 -0
- package/build/api/index.js.map +1 -0
- package/build/api/vite/plugins/build.d.ts +2 -2
- package/build/api/vite/plugins/build.d.ts.map +1 -1
- package/build/api/vite/plugins/build.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts +2 -2
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +20 -8
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/api/vite/plugins/main.d.ts +2 -2
- package/build/api/vite/plugins/main.d.ts.map +1 -1
- package/build/api/vite/plugins/main.js +19 -18
- package/build/api/vite/plugins/main.js.map +1 -1
- package/build/api/vite/plugins/serve.d.ts +2 -2
- package/build/api/vite/plugins/serve.d.ts.map +1 -1
- package/build/api/vite/plugins/serve.js.map +1 -1
- package/build/cli/commands/$default.js +1 -1
- package/build/cli/commands/$default.js.map +1 -1
- package/build/cli/commands/build.js +3 -5
- package/build/cli/commands/build.js.map +1 -1
- package/build/cli/commands/dev.js +8 -15
- package/build/cli/commands/dev.js.map +1 -1
- package/build/cli/commands/open.js +2 -2
- package/build/cli/commands/open.js.map +1 -1
- package/build/cli/index.js +6 -0
- package/build/cli/index.js.map +1 -1
- package/build/exports/polen.d.ts +3 -3
- package/build/exports/polen.d.ts.map +1 -1
- package/build/exports/polen.js +3 -3
- package/build/exports/polen.js.map +1 -1
- package/build/lib/file-router/linter.js +2 -2
- package/build/lib/file-router/linter.js.map +1 -1
- package/build/lib/kit-temp.d.ts +5 -0
- package/build/lib/kit-temp.d.ts.map +1 -1
- package/build/lib/kit-temp.js +29 -0
- package/build/lib/kit-temp.js.map +1 -1
- package/build/lib/vite-plugin-mdx/index.d.ts +2 -0
- package/build/lib/vite-plugin-mdx/index.d.ts.map +1 -0
- package/build/lib/vite-plugin-mdx/index.js +4 -0
- package/build/lib/vite-plugin-mdx/index.js.map +1 -0
- package/build/lib/vite-plugin-mdx/vite-plugin-mdx.d.ts +2 -0
- package/build/lib/vite-plugin-mdx/vite-plugin-mdx.d.ts.map +1 -0
- package/build/lib/vite-plugin-mdx/vite-plugin-mdx.js +74 -0
- package/build/lib/vite-plugin-mdx/vite-plugin-mdx.js.map +1 -0
- package/build/lib/vite-plugins/vite-plugins.d.ts +0 -1
- package/build/lib/vite-plugins/vite-plugins.d.ts.map +1 -1
- package/build/lib/vite-plugins/vite-plugins.js +0 -1
- package/build/lib/vite-plugins/vite-plugins.js.map +1 -1
- package/build/lib/vite-virtual/identified-loader.d.ts.map +1 -1
- package/build/lib/vite-virtual/identified-loader.js +4 -0
- package/build/lib/vite-virtual/identified-loader.js.map +1 -1
- package/build/project-data.d.ts +2 -2
- package/build/project-data.d.ts.map +1 -1
- package/build/template/server/render-page.jsx +1 -1
- package/build/template/server/render-page.jsx.map +1 -1
- package/package.json +11 -6
- package/src/api/api.ts +3 -0
- package/src/api/{build/build.ts → builder/builder.ts} +11 -14
- package/src/api/builder/index.ts +1 -0
- package/src/api/config/config.ts +4 -0
- package/src/api/{configurator → config}/configurator.ts +61 -42
- package/src/api/config/define.ts +8 -0
- package/src/api/config/index.ts +1 -0
- package/src/api/config/load.ts +52 -0
- package/src/api/config/merge.ts +68 -0
- package/src/api/config-resolver/config-resolver.ts +2 -0
- package/src/api/config-resolver/index.ts +1 -0
- package/src/api/config-resolver/resolve.ts +28 -0
- package/src/api/config-resolver/vite.ts +27 -0
- package/src/api/index.ts +1 -0
- package/src/api/vite/plugins/build.ts +3 -3
- package/src/api/vite/plugins/core.ts +22 -10
- package/src/api/vite/plugins/main.ts +21 -20
- package/src/api/vite/plugins/serve.ts +2 -2
- package/src/cli/commands/$default.ts +1 -1
- package/src/cli/commands/build.ts +3 -5
- package/src/cli/commands/dev.ts +8 -15
- package/src/cli/commands/open.ts +2 -2
- package/src/cli/index.ts +7 -0
- package/src/exports/polen.ts +3 -3
- package/src/lib/file-router/linter.ts +2 -2
- package/src/lib/kit-temp.ts +30 -0
- package/src/lib/vite-plugin-mdx/index.ts +2 -0
- package/src/lib/vite-plugin-mdx/vite-plugin-mdx.ts +81 -0
- package/src/lib/vite-plugins/vite-plugins.ts +0 -1
- package/src/lib/vite-virtual/identified-loader.ts +4 -0
- package/src/project-data.ts +2 -2
- package/src/template/server/render-page.tsx +1 -1
- package/build/api/build/build.d.ts.map +0 -1
- package/build/api/build/build.js.map +0 -1
- package/build/api/configurator/configurator.d.ts.map +0 -1
- package/build/api/configurator/configurator.js.map +0 -1
- package/build/api/configurator/index.d.ts +0 -2
- package/build/api/configurator/index.d.ts.map +0 -1
- package/build/api/configurator/index.js +0 -2
- package/build/api/configurator/index.js.map +0 -1
- package/build/api/define-config.d.ts +0 -13
- package/build/api/define-config.d.ts.map +0 -1
- package/build/api/define-config.js +0 -23
- package/build/api/define-config.js.map +0 -1
- package/build/api/load-config.d.ts +0 -9
- package/build/api/load-config.d.ts.map +0 -1
- package/build/api/load-config.js +0 -39
- package/build/api/load-config.js.map +0 -1
- package/build/api/vite/vite-plugin-delete.d.ts +0 -2
- package/build/api/vite/vite-plugin-delete.d.ts.map +0 -1
- package/build/api/vite/vite-plugin-delete.js +0 -11
- package/build/api/vite/vite-plugin-delete.js.map +0 -1
- package/build/lib/vite-plugins/output-logger.d.ts +0 -3
- package/build/lib/vite-plugins/output-logger.d.ts.map +0 -1
- package/build/lib/vite-plugins/output-logger.js +0 -13
- package/build/lib/vite-plugins/output-logger.js.map +0 -1
- package/src/api/configurator/index.ts +0 -1
- package/src/api/define-config.ts +0 -35
- package/src/api/load-config.ts +0 -54
- package/src/api/vite/vite-plugin-delete.ts +0 -10
- package/src/lib/vite-plugins/output-logger.ts +0 -14
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vite-plugin-mdx.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-plugin-mdx/vite-plugin-mdx.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// TODO: use this or similar once transform hook can change module type and have result re-processed
|
2
|
+
// @see https://github.com/rolldown/rolldown/issues/4004
|
3
|
+
export {};
|
4
|
+
// import type { CompileOptions } from '@mdx-js/mdx'
|
5
|
+
// import {
|
6
|
+
// createFormatAwareProcessors,
|
7
|
+
// type FormatAwareProcessors,
|
8
|
+
// } from '@mdx-js/mdx/internal-create-format-aware-processors'
|
9
|
+
// import { createFilter, type FilterPattern } from '@rollup/pluginutils'
|
10
|
+
// import type { SourceDescription } from 'rolldown'
|
11
|
+
// import { SourceMapGenerator } from 'source-map'
|
12
|
+
// import { VFile } from 'vfile'
|
13
|
+
// import type { Plugin } from 'vite'
|
14
|
+
// type ApplicableOptions = Omit<CompileOptions, `SourceMapGenerator`>
|
15
|
+
// interface ExtraOptions {
|
16
|
+
// /**
|
17
|
+
// * Picomatch patterns to exclude (optional).
|
18
|
+
// */
|
19
|
+
// exclude?: FilterPattern | null | undefined
|
20
|
+
// /**
|
21
|
+
// * Picomatch patterns to include (optional).
|
22
|
+
// */
|
23
|
+
// include?: FilterPattern | null | undefined
|
24
|
+
// }
|
25
|
+
// export type Options = ApplicableOptions & ExtraOptions
|
26
|
+
// /**
|
27
|
+
// * Plugin to compile MDX w/ rolldown.
|
28
|
+
// */
|
29
|
+
// export function VitePluginMdx(options?: Readonly<Options> | null): Plugin {
|
30
|
+
// const {
|
31
|
+
// exclude,
|
32
|
+
// include = /\.mdx?$/, // Default to .md and .mdx files
|
33
|
+
// ...rest
|
34
|
+
// } = options ?? {}
|
35
|
+
// let formatAwareProcessors: FormatAwareProcessors
|
36
|
+
// const filter = createFilter(include, exclude)
|
37
|
+
// return {
|
38
|
+
// name: `@mdx-js/rolldown`,
|
39
|
+
// enforce: `pre`, // Run before other transforms
|
40
|
+
// config(config, env) {
|
41
|
+
// // Initialize processors with Vite environment info
|
42
|
+
// formatAwareProcessors = createFormatAwareProcessors({
|
43
|
+
// SourceMapGenerator,
|
44
|
+
// development: env.mode === `development`,
|
45
|
+
// ...rest,
|
46
|
+
// })
|
47
|
+
// },
|
48
|
+
// async transform(value: string, id: string): Promise<SourceDescription | undefined> {
|
49
|
+
// // Ensure processors are initialized
|
50
|
+
// // if (!formatAwareProcessors) {
|
51
|
+
// // formatAwareProcessors = createFormatAwareProcessors({
|
52
|
+
// // SourceMapGenerator,
|
53
|
+
// // ...rest,
|
54
|
+
// // })
|
55
|
+
// // }
|
56
|
+
// const file = new VFile({ path: id, value })
|
57
|
+
// if (
|
58
|
+
// file.extname
|
59
|
+
// && filter(file.path)
|
60
|
+
// && formatAwareProcessors.extnames.includes(file.extname)
|
61
|
+
// ) {
|
62
|
+
// const compiled = await formatAwareProcessors.process(file)
|
63
|
+
// const code = String(compiled.value)
|
64
|
+
// const result: SourceDescription = {
|
65
|
+
// code,
|
66
|
+
// // When MDX compiles to JS (not JSX), we don't need to set moduleType
|
67
|
+
// map: compiled.map,
|
68
|
+
// }
|
69
|
+
// return result
|
70
|
+
// }
|
71
|
+
// },
|
72
|
+
// }
|
73
|
+
// }
|
74
|
+
//# sourceMappingURL=vite-plugin-mdx.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"vite-plugin-mdx.js","sourceRoot":"","sources":["../../../src/lib/vite-plugin-mdx/vite-plugin-mdx.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,yDAAyD;;AAEzD,oDAAoD;AACpD,WAAW;AACX,iCAAiC;AACjC,gCAAgC;AAChC,+DAA+D;AAC/D,yEAAyE;AACzE,oDAAoD;AACpD,kDAAkD;AAClD,gCAAgC;AAChC,qCAAqC;AAErC,sEAAsE;AAEtE,2BAA2B;AAC3B,QAAQ;AACR,iDAAiD;AACjD,QAAQ;AACR,+CAA+C;AAC/C,QAAQ;AACR,iDAAiD;AACjD,QAAQ;AACR,+CAA+C;AAC/C,IAAI;AAEJ,yDAAyD;AAEzD,MAAM;AACN,wCAAwC;AACxC,MAAM;AACN,8EAA8E;AAC9E,YAAY;AACZ,eAAe;AACf,4DAA4D;AAC5D,cAAc;AACd,sBAAsB;AACtB,qDAAqD;AACrD,kDAAkD;AAElD,aAAa;AACb,gCAAgC;AAChC,qDAAqD;AACrD,4BAA4B;AAC5B,4DAA4D;AAC5D,8DAA8D;AAC9D,8BAA8B;AAC9B,mDAAmD;AACnD,mBAAmB;AACnB,WAAW;AACX,SAAS;AACT,2FAA2F;AAC3F,6CAA6C;AAC7C,yCAAyC;AACzC,mEAAmE;AACnE,mCAAmC;AACnC,wBAAwB;AACxB,gBAAgB;AAChB,aAAa;AAEb,oDAAoD;AAEpD,aAAa;AACb,uBAAuB;AACvB,+BAA+B;AAC/B,mEAAmE;AACnE,YAAY;AACZ,qEAAqE;AACrE,8CAA8C;AAC9C,8CAA8C;AAC9C,kBAAkB;AAClB,kFAAkF;AAClF,+BAA+B;AAC/B,YAAY;AAEZ,wBAAwB;AACxB,UAAU;AACV,SAAS;AACT,MAAM;AACN,IAAI"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vite-plugins.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-plugins/vite-plugins.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA
|
1
|
+
{"version":3,"file":"vite-plugins.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-plugins/vite-plugins.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"vite-plugins.js","sourceRoot":"","sources":["../../../src/lib/vite-plugins/vite-plugins.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA
|
1
|
+
{"version":3,"file":"vite-plugins.js","sourceRoot":"","sources":["../../../src/lib/vite-plugins/vite-plugins.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"identified-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-virtual/identified-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,IAAI,CAAC,cAAc,CAAA;CAC5B;AAED,eAAO,MAAM,UAAU,GACrB,kBAAkB,gBAAgB,KACjC,
|
1
|
+
{"version":3,"file":"identified-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/vite-virtual/identified-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAG9C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,IAAI,CAAC,cAAc,CAAA;CAC5B;AAED,eAAO,MAAM,UAAU,GACrB,kBAAkB,gBAAgB,KACjC,QAeF,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,kBAAkB,gBAAgB,KAAG,aAOpE,CAAA;AAED,eAAO,MAAM,OAAO,GAClB,GAAG,mBAAmB,gBAAgB,EAAE,KACvC;IACD,SAAS,EAAE,IAAI,CAAC,mBAAmB,CAAA;IACnC,IAAI,EAAE,IAAI,CAAC,cAAc,CAAA;CAc1B,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,GAAG,mBAAmB,gBAAgB,EAAE,KAAG,IAAI,CAAC,MAKxE,CAAA"}
|
@@ -7,6 +7,10 @@ export const toHookLoad = (identifiedLoader) => {
|
|
7
7
|
debug(`will load`, { identifier: identifiedLoader.identifier });
|
8
8
|
const result = await identifiedLoader.loader(...args);
|
9
9
|
debug(`did load`, { identifier: identifiedLoader.identifier, result });
|
10
|
+
// Add moduleType for Rolldown compatibility
|
11
|
+
if (result && typeof result === `string`) {
|
12
|
+
return { code: result, moduleType: `js` };
|
13
|
+
}
|
10
14
|
return result;
|
11
15
|
}
|
12
16
|
return undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"identified-loader.js","sourceRoot":"","sources":["../../../src/lib/vite-virtual/identified-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAS5D,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,gBAAkC,EACxB,EAAE;IACZ,OAAO,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;QACvB,uDAAuD;QACvD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACrD,KAAK,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAA;YAC/D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;YACrD,KAAK,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;YACtE,OAAO,MAAM,CAAA;QACf,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,gBAAkC,EAAiB,EAAE;IACnF,OAAO,EAAE,CAAC,EAAE;QACV,IAAI,EAAE,KAAK,gBAAgB,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;YAC1C,OAAO,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAA;QAC7C,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,GAAG,iBAAqC,EAIxC,EAAE;IACF,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,CAC3C,iBAAiB,CAAC,GAAG,CAAC,eAAe,CAAC,CACvC,CAAA;IAED,MAAM,IAAI,GAAG,cAAc,CAAC,YAAY,CACtC,iBAAiB,CAAC,GAAG,CAAC,UAAU,CAAC,CAClC,CAAA;IAED,OAAO;QACL,SAAS;QACT,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,iBAAqC,EAAe,EAAE;IAChF,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,GAAG,OAAO,CAAC,GAAG,iBAAiB,CAAC;KACjC,CAAA;AACH,CAAC,CAAA"}
|
1
|
+
{"version":3,"file":"identified-loader.js","sourceRoot":"","sources":["../../../src/lib/vite-virtual/identified-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAS5D,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,gBAAkC,EACxB,EAAE;IACZ,OAAO,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE;QACvB,uDAAuD;QACvD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACrD,KAAK,CAAC,WAAW,EAAE,E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,iBAAiB,CAAC;KACjC,CAAA;AACH,CAAC,CAAA"}
|
package/build/project-data.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
+
import type { Config } from '#api/config/index.js';
|
1
2
|
import type { FileRouter } from '#lib/file-router/index.js';
|
2
|
-
import type { Configurator } from './api/configurator/index.js';
|
3
3
|
import type { Schema } from './api/schema/index.js';
|
4
4
|
export interface ProjectData {
|
5
5
|
schema: null | Schema.Schema;
|
6
6
|
siteNavigationItems: SiteNavigationItem[];
|
7
7
|
sidebarIndex: SidebarIndex;
|
8
8
|
faviconPath: string;
|
9
|
-
paths:
|
9
|
+
paths: Config.Config[`paths`][`project`];
|
10
10
|
pagesScanResult: FileRouter.ScanResult;
|
11
11
|
server: {
|
12
12
|
static: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"project-data.d.ts","sourceRoot":"","sources":["../src/project-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"project-data.d.ts","sourceRoot":"","sources":["../src/project-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAEnD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,CAAA;IAC5B,mBAAmB,EAAE,kBAAkB,EAAE,CAAA;IACzC,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAA;IACxC,eAAe,EAAE,UAAU,CAAC,UAAU,CAAA;IACtC,MAAM,EAAE;QACN,MAAM,EAAE;YACN,SAAS,EAAE,MAAM,CAAA;YACjB,KAAK,EAAE,MAAM,CAAA;SACd,CAAA;KACF,CAAA;CACF;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAA;CAClC;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,WAAW,EAAE,CAAA;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,cAAc,CAAA;AAErD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,UAAU,EAAE,CAAA;CACnB"}
|
@@ -40,7 +40,7 @@ const getStatusCode = (context) => {
|
|
40
40
|
return context.statusCode;
|
41
41
|
}
|
42
42
|
// Then check for custom status in route handle
|
43
|
-
const handle = Arr.
|
43
|
+
const handle = Arr.getLast(context.matches)?.route.handle;
|
44
44
|
if (handle?.statusCode) {
|
45
45
|
return handle.statusCode;
|
46
46
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"render-page.jsx","sourceRoot":"","sources":["../../../src/template/server/render-page.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,uBAAuB,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAA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I,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,CAAA;IAC1C,IAAI,aAAa,EAAE,CAAC;QAClB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "polen",
|
3
|
-
"version": "0.8.0-next.
|
3
|
+
"version": "0.8.0-next.9",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A framework for delightful GraphQL developer portals",
|
6
6
|
"author": {
|
@@ -53,15 +53,17 @@
|
|
53
53
|
"@graphql-inspector/core": "^6.2.1",
|
54
54
|
"@graphql-tools/load": "^8.1.0",
|
55
55
|
"@hono/node-server": "^1.14.1",
|
56
|
-
"@
|
56
|
+
"@mdx-js/mdx": "^3.1.0",
|
57
57
|
"@mdx-js/rollup": "^3.1.0",
|
58
58
|
"@radix-ui/react-icons": "^1.3.2",
|
59
59
|
"@radix-ui/themes": "^3.2.1",
|
60
60
|
"@rolldown/pluginutils": "1.0.0-beta.9",
|
61
|
+
"@rollup/pluginutils": "^5.1.4",
|
61
62
|
"@swc/core": "^1.11.29",
|
62
63
|
"@types/jsesc": "^3.0.3",
|
63
|
-
"@vitejs/plugin-react": "^4.
|
64
|
-
"@
|
64
|
+
"@vitejs/plugin-react": "^4.5.1",
|
65
|
+
"@vitejs/plugin-react-oxc": "^0.2.1",
|
66
|
+
"@wollybeard/kit": "^0.34.0",
|
65
67
|
"@wollybeard/projector": "^0.1.1",
|
66
68
|
"ansis": "^4.0.0",
|
67
69
|
"consola": "^3.4.2",
|
@@ -80,10 +82,14 @@
|
|
80
82
|
"remark-gfm": "^4.0.0",
|
81
83
|
"remark-html": "^16.0.1",
|
82
84
|
"resolve.imports": "^2.0.3",
|
85
|
+
"rolldown": "1.0.0-beta.11",
|
86
|
+
"source-map": "^0.7.4",
|
83
87
|
"superjson": "^2.2.2",
|
84
88
|
"tinyglobby": "^0.2.13",
|
89
|
+
"tsx": "^4.19.4",
|
85
90
|
"typescript": "^5.8.3",
|
86
|
-
"
|
91
|
+
"vfile": "^6.0.3",
|
92
|
+
"vite": "npm:rolldown-vite@~6.3.17",
|
87
93
|
"vite-plugin-inspect": "^11.0.1",
|
88
94
|
"vite-plugin-restart": "^0.4.2",
|
89
95
|
"zx": "8.5.4"
|
@@ -117,7 +123,6 @@
|
|
117
123
|
"playwright": "^1.52.0",
|
118
124
|
"publint": "^0.3.12",
|
119
125
|
"strip-ansi": "^7.1.0",
|
120
|
-
"tsx": "^4.19.4",
|
121
126
|
"type-fest": "^4.40.1",
|
122
127
|
"typescript": "^5.8.3",
|
123
128
|
"typescript-eslint": "^8.31.1",
|
package/src/api/api.ts
ADDED
@@ -1,27 +1,24 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { ConfigResolver } from '#api/config-resolver/index.js'
|
2
|
+
import { Config } from '#api/config/index.js'
|
3
3
|
import { Vite } from '#dep/vite/index.js'
|
4
4
|
import { Fs } from '@wollybeard/kit'
|
5
5
|
import consola from 'consola'
|
6
6
|
|
7
7
|
const buildDefaults = {
|
8
8
|
debug: false,
|
9
|
-
architecture:
|
9
|
+
architecture: Config.BuildArchitecture.enum.ssg,
|
10
10
|
}
|
11
11
|
|
12
12
|
interface BuildConfigInput {
|
13
13
|
debug?: boolean
|
14
|
-
architecture?:
|
14
|
+
architecture?: Config.BuildArchitecture
|
15
15
|
}
|
16
16
|
|
17
17
|
export const build = async (buildConfigInput: BuildConfigInput) => {
|
18
18
|
const buildConfig = { ...buildDefaults, ...buildConfigInput }
|
19
19
|
|
20
|
-
const
|
21
|
-
|
22
|
-
command: `build`,
|
23
|
-
mode: `production`,
|
24
|
-
},
|
20
|
+
const viteUserConfig = await ConfigResolver.fromFile({
|
21
|
+
dir: process.cwd(),
|
25
22
|
overrides: {
|
26
23
|
build: {
|
27
24
|
architecture: buildConfig.architecture,
|
@@ -32,19 +29,19 @@ export const build = async (buildConfigInput: BuildConfigInput) => {
|
|
32
29
|
},
|
33
30
|
})
|
34
31
|
|
35
|
-
const builder = await Vite.createBuilder(
|
32
|
+
const builder = await Vite.createBuilder(viteUserConfig)
|
36
33
|
await builder.buildApp()
|
37
34
|
|
38
35
|
if (buildConfig.architecture === `ssg`) {
|
39
36
|
consola.info(`Generating static site...`)
|
40
|
-
await import(
|
37
|
+
await import(viteUserConfig._polen.paths.project.absolute.build.serverEntrypoint)
|
41
38
|
// Clean up server file which should now be done being used for SSG geneation.
|
42
|
-
await Fs.remove(
|
39
|
+
await Fs.remove(viteUserConfig._polen.paths.project.absolute.build.serverEntrypoint)
|
43
40
|
// todo: there is also some kind of prompt js asset that we probably need to clean up or review...
|
44
41
|
consola.success(`Done`)
|
45
|
-
consola.info(`try it: npx serve ${
|
42
|
+
consola.info(`try it: npx serve ${viteUserConfig._polen.paths.project.relative.build.root} -p 4000`)
|
46
43
|
} else if (buildConfig.architecture === `ssr`) {
|
47
|
-
consola.info(`try it: node ${
|
44
|
+
consola.info(`try it: node ${viteUserConfig._polen.paths.project.relative.build.root}/app.js`)
|
48
45
|
// todo: no hardcoded port
|
49
46
|
consola.info(`Then visit http://localhost:3001`)
|
50
47
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as Builder from './builder.js'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Vite } from '#dep/vite/index.js'
|
2
|
+
import { assertPathAbsolute } from '#lib/kit-temp.js'
|
2
3
|
import { Path } from '@wollybeard/kit'
|
3
4
|
import { z } from 'zod'
|
4
5
|
import type { SchemaAugmentation } from '../../api/schema-augmentation/index.js'
|
@@ -21,9 +22,9 @@ export interface ConfigInput {
|
|
21
22
|
/**
|
22
23
|
* Path to the root directory of your project.
|
23
24
|
*
|
24
|
-
* Relative paths will be resolved relative to
|
25
|
+
* Relative paths will be resolved relative to this config file.
|
25
26
|
*
|
26
|
-
* @defaultValue
|
27
|
+
* @defaultValue The directory where the config file is located.
|
27
28
|
*/
|
28
29
|
root?: string
|
29
30
|
/**
|
@@ -90,7 +91,37 @@ export interface TemplateVariables {
|
|
90
91
|
title: string
|
91
92
|
}
|
92
93
|
|
94
|
+
const buildPaths = (rootDir: string): Config[`paths`] => {
|
95
|
+
if (!Path.isAbsolute(rootDir)) throw new Error(`Root dir path must be absolute: ${rootDir}`)
|
96
|
+
const ensureAbsolute = Path.ensureAbsoluteWith(rootDir)
|
97
|
+
return {
|
98
|
+
project: {
|
99
|
+
rootDir,
|
100
|
+
relative: {
|
101
|
+
build: {
|
102
|
+
root: `build`,
|
103
|
+
relative: {
|
104
|
+
serverEntrypoint: `app.js`,
|
105
|
+
assets: `assets`,
|
106
|
+
},
|
107
|
+
},
|
108
|
+
pages: `pages`,
|
109
|
+
},
|
110
|
+
absolute: {
|
111
|
+
build: {
|
112
|
+
root: ensureAbsolute(`build`),
|
113
|
+
serverEntrypoint: ensureAbsolute(`build/app.js`),
|
114
|
+
assets: ensureAbsolute(`build/assets`),
|
115
|
+
},
|
116
|
+
pages: ensureAbsolute(`pages`),
|
117
|
+
},
|
118
|
+
},
|
119
|
+
framework: packagePaths,
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
93
123
|
export interface Config {
|
124
|
+
_input: ConfigInput
|
94
125
|
build: {
|
95
126
|
architecture: BuildArchitecture
|
96
127
|
}
|
@@ -135,6 +166,7 @@ export interface Config {
|
|
135
166
|
}
|
136
167
|
|
137
168
|
const configInputDefaults: Config = {
|
169
|
+
_input: {},
|
138
170
|
templateVariables: {
|
139
171
|
title: `My Developer Portal`,
|
140
172
|
},
|
@@ -149,30 +181,7 @@ const configInputDefaults: Config = {
|
|
149
181
|
ssr: {
|
150
182
|
enabled: true,
|
151
183
|
},
|
152
|
-
paths:
|
153
|
-
project: {
|
154
|
-
rootDir: process.cwd(),
|
155
|
-
relative: {
|
156
|
-
build: {
|
157
|
-
root: `build`,
|
158
|
-
relative: {
|
159
|
-
serverEntrypoint: `app.js`,
|
160
|
-
assets: `assets`,
|
161
|
-
},
|
162
|
-
},
|
163
|
-
pages: `pages`,
|
164
|
-
},
|
165
|
-
absolute: {
|
166
|
-
build: {
|
167
|
-
root: Path.ensureAbsoluteWithCWD(`build`),
|
168
|
-
serverEntrypoint: Path.ensureAbsoluteWithCWD(`build/app.js`),
|
169
|
-
assets: Path.ensureAbsoluteWithCWD(`build/assets`),
|
170
|
-
},
|
171
|
-
pages: Path.ensureAbsoluteWithCWD(`pages`),
|
172
|
-
},
|
173
|
-
},
|
174
|
-
framework: packagePaths,
|
175
|
-
},
|
184
|
+
paths: buildPaths(process.cwd()),
|
176
185
|
advanced: {
|
177
186
|
debug: false,
|
178
187
|
explorer: false,
|
@@ -180,11 +189,26 @@ const configInputDefaults: Config = {
|
|
180
189
|
}
|
181
190
|
|
182
191
|
export const normalizeInput = async (
|
183
|
-
configInput
|
192
|
+
configInput: ConfigInput | undefined,
|
193
|
+
/**
|
194
|
+
* If the input has a relative root path, then resolve it relative to this path.
|
195
|
+
*
|
196
|
+
* We tell users relative paths are resolved to the config file directory.
|
197
|
+
* Config loaders should pass the directory of the config file here to ensure that happens.
|
198
|
+
*
|
199
|
+
* If this is omitted, then relative root paths will throw an error.
|
200
|
+
*/
|
201
|
+
baseRootDirPath: string,
|
184
202
|
// eslint-disable-next-line
|
185
203
|
): Promise<Config> => {
|
204
|
+
assertPathAbsolute(baseRootDirPath)
|
205
|
+
|
186
206
|
const config = structuredClone(configInputDefaults)
|
187
207
|
|
208
|
+
if (configInput) {
|
209
|
+
config._input = configInput
|
210
|
+
}
|
211
|
+
|
188
212
|
if (configInput?.build?.architecture) {
|
189
213
|
config.build.architecture = configInput.build.architecture
|
190
214
|
}
|
@@ -193,21 +217,16 @@ export const normalizeInput = async (
|
|
193
217
|
config.advanced.debug = configInput.advanced.debug
|
194
218
|
}
|
195
219
|
|
196
|
-
if (configInput?.root) {
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
)
|
203
|
-
config.paths
|
204
|
-
|
205
|
-
|
206
|
-
)
|
207
|
-
config.paths.project.absolute.pages = Path.join(
|
208
|
-
config.paths.project.rootDir,
|
209
|
-
config.paths.project.relative.pages,
|
210
|
-
)
|
220
|
+
if (configInput?.root !== undefined) {
|
221
|
+
if (!baseRootDirPath && !Path.isAbsolute(configInput.root)) {
|
222
|
+
throw new Error(
|
223
|
+
`Root path must be absolute or baseRootPath must be provided to resolve relative root paths. Provided: ${configInput.root}`,
|
224
|
+
)
|
225
|
+
}
|
226
|
+
const root = Path.ensureAbsolute(configInput.root, baseRootDirPath)
|
227
|
+
config.paths = buildPaths(root)
|
228
|
+
} else if (baseRootDirPath) {
|
229
|
+
config.paths = buildPaths(baseRootDirPath)
|
211
230
|
}
|
212
231
|
|
213
232
|
if (configInput?.advanced?.vite) {
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Fn } from '@wollybeard/kit'
|
2
|
+
import type { ConfigInput } from './configurator.js'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Define a Polen configuration.
|
6
|
+
* This is an identity function that provides type safety for config files.
|
7
|
+
*/
|
8
|
+
export const defineConfig = Fn.identity<ConfigInput>
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as Config from './config.js'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { assertOptionalPathAbsolute, pickFirstPathExisting } from '#lib/kit-temp.js'
|
2
|
+
import type { Prom } from '@wollybeard/kit'
|
3
|
+
import { Path } from '@wollybeard/kit'
|
4
|
+
import type { ConfigInput } from './configurator.js'
|
5
|
+
|
6
|
+
export const fileNameBases = [`polen.config`, `.polen.config`]
|
7
|
+
export const fileNameExtensionsTypeScript = [`.ts`, `.js`, `.mjs`, `.mts`]
|
8
|
+
export const fileNameExtensionsJavaScript = [`.js`, `.mjs`]
|
9
|
+
export const fileNameExtensions = [...fileNameExtensionsTypeScript, ...fileNameExtensionsJavaScript]
|
10
|
+
export const fileNames = fileNameBases.flatMap(base => fileNameExtensions.map(ext => `${base}${ext}`))
|
11
|
+
|
12
|
+
export interface LoadOptions {
|
13
|
+
dir: string
|
14
|
+
}
|
15
|
+
|
16
|
+
export const load = async (options: LoadOptions): Promise<ConfigInput> => {
|
17
|
+
assertOptionalPathAbsolute(options.dir)
|
18
|
+
|
19
|
+
const filePaths = fileNames.map(fileName => Path.join(options.dir, fileName))
|
20
|
+
const filePath = await pickFirstPathExisting(filePaths)
|
21
|
+
|
22
|
+
if (!filePath) return {}
|
23
|
+
|
24
|
+
let module: { default?: Prom.Maybe<ConfigInput>; config?: Prom.Maybe<ConfigInput> }
|
25
|
+
|
26
|
+
if (fileNameExtensionsTypeScript.some(_ => filePath.endsWith(_))) {
|
27
|
+
// @see https://tsx.is/dev-api/ts-import#usage
|
28
|
+
const { tsImport } = await import(`tsx/esm/api`)
|
29
|
+
// eslint-disable-next-line
|
30
|
+
module = await tsImport(filePath, import.meta.url)
|
31
|
+
} else {
|
32
|
+
// eslint-disable-next-line
|
33
|
+
module = await import(filePath)
|
34
|
+
}
|
35
|
+
|
36
|
+
// // Use dynamic import with file URL to support Windows
|
37
|
+
// const configUrl = pathToFileURL(configPath).href
|
38
|
+
|
39
|
+
// todo: report errors nicely if this fails
|
40
|
+
const configInput = await (module.default ?? module.config)
|
41
|
+
|
42
|
+
// todo: check schema of configInput
|
43
|
+
|
44
|
+
// todo: report errors nicely
|
45
|
+
if (!configInput) {
|
46
|
+
throw new Error(
|
47
|
+
`Your Polen config module (${filePath}) must export a config. You can use a default export or named export of \`config\`.`,
|
48
|
+
)
|
49
|
+
}
|
50
|
+
|
51
|
+
return configInput
|
52
|
+
}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
import { Vite } from '#dep/vite/index.js'
|
2
|
+
import type { ConfigInput } from './configurator.js'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Deep merge two Polen config inputs.
|
6
|
+
* The second config (overrides) takes precedence over the first (base).
|
7
|
+
*/
|
8
|
+
export const mergeInputs = (
|
9
|
+
base: ConfigInput,
|
10
|
+
// eslint-disable-next-line
|
11
|
+
overrides?: ConfigInput | undefined,
|
12
|
+
): ConfigInput => {
|
13
|
+
if (!overrides) {
|
14
|
+
return base
|
15
|
+
}
|
16
|
+
|
17
|
+
const merged: ConfigInput = {
|
18
|
+
...base,
|
19
|
+
...overrides,
|
20
|
+
}
|
21
|
+
|
22
|
+
// Merge schema if both have it
|
23
|
+
if (base.schema || overrides.schema) {
|
24
|
+
merged.schema = overrides.schema ?? base.schema
|
25
|
+
}
|
26
|
+
|
27
|
+
// Merge build config
|
28
|
+
if (base.build || overrides.build) {
|
29
|
+
merged.build = {
|
30
|
+
...base.build,
|
31
|
+
...overrides.build,
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
// Merge advanced config
|
36
|
+
if (base.advanced || overrides.advanced) {
|
37
|
+
merged.advanced = {
|
38
|
+
...base.advanced,
|
39
|
+
...overrides.advanced,
|
40
|
+
}
|
41
|
+
|
42
|
+
// Merge advanced.watch config
|
43
|
+
if (base.advanced?.watch || overrides.advanced?.watch) {
|
44
|
+
merged.advanced.watch = {
|
45
|
+
...base.advanced?.watch,
|
46
|
+
...overrides.advanced?.watch,
|
47
|
+
}
|
48
|
+
|
49
|
+
// Merge watch.also arrays
|
50
|
+
if (base.advanced?.watch?.also || overrides.advanced?.watch?.also) {
|
51
|
+
merged.advanced.watch.also = [
|
52
|
+
...(base.advanced?.watch?.also ?? []),
|
53
|
+
...(overrides.advanced?.watch?.also ?? []),
|
54
|
+
]
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
// Merge Vite configs if present
|
59
|
+
if (base.advanced?.vite ?? overrides.advanced?.vite) {
|
60
|
+
merged.advanced.vite = Vite.mergeConfig(
|
61
|
+
base.advanced?.vite ?? {},
|
62
|
+
overrides.advanced?.vite ?? {},
|
63
|
+
)
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
return merged
|
68
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as ConfigResolver from './config-resolver.js'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { type ConfigInput, normalizeInput } from '../config/configurator.js'
|
2
|
+
import { load, type LoadOptions } from '../config/load.js'
|
3
|
+
import { mergeInputs } from '../config/merge.js'
|
4
|
+
import { toViteUserConfig, type ViteUserConfigWithPolen } from './vite.js'
|
5
|
+
|
6
|
+
interface ResolveFromFileOptions extends LoadOptions {
|
7
|
+
overrides?: ConfigInput
|
8
|
+
}
|
9
|
+
|
10
|
+
export const fromFile = async (options: ResolveFromFileOptions): Promise<ViteUserConfigWithPolen> => {
|
11
|
+
const configInput = await load(options)
|
12
|
+
const configInputMerged = mergeInputs(configInput, options.overrides)
|
13
|
+
return fromMemory(configInputMerged, options.dir)
|
14
|
+
}
|
15
|
+
|
16
|
+
export const fromMemory = async (
|
17
|
+
input: ConfigInput,
|
18
|
+
/**
|
19
|
+
* Refer to `baseRootDirPath` parameter on {@link normalizeInput}.
|
20
|
+
*
|
21
|
+
* @defaultValue `process.cwd()`
|
22
|
+
*/
|
23
|
+
baseRootDirPath?: string,
|
24
|
+
) => {
|
25
|
+
const configNormalized = await normalizeInput(input, baseRootDirPath ?? process.cwd())
|
26
|
+
const viteUserConfig = toViteUserConfig(configNormalized)
|
27
|
+
return viteUserConfig
|
28
|
+
}
|