@genesislcap/vite-builder 15.19.0 → 15.19.1-GENC-1557.2
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/package.json +3 -4
- package/src/index.ts +0 -212
- package/src/vite.ts +0 -24
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/vite-builder",
|
|
3
3
|
"description": "Vite builder",
|
|
4
|
-
"version": "15.19.
|
|
4
|
+
"version": "15.19.1-GENC-1557.2",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"lint:fix": "genx lint -l ox --fix"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@genesislcap/build-kit": "15.19.
|
|
19
|
+
"@genesislcap/build-kit": "15.19.1-GENC-1557.2",
|
|
20
20
|
"consola": "^3.0.2",
|
|
21
21
|
"copyfiles": "^2.4.1",
|
|
22
22
|
"vite": "^7.2.2",
|
|
@@ -30,6 +30,5 @@
|
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
|
-
}
|
|
34
|
-
"gitHead": "83695de98c2288c2e89992215cb391652f6c5eec"
|
|
33
|
+
}
|
|
35
34
|
}
|
package/src/index.ts
DELETED
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { relative, resolve } from 'node:path';
|
|
3
|
-
import type { BuildContext } from '@genesislcap/build-kit';
|
|
4
|
-
import {
|
|
5
|
-
createDevProxies,
|
|
6
|
-
getDevCertOptions,
|
|
7
|
-
getPort,
|
|
8
|
-
getPublicPath,
|
|
9
|
-
resolveBin,
|
|
10
|
-
resolveDefineConfig,
|
|
11
|
-
run,
|
|
12
|
-
} from '@genesislcap/build-kit';
|
|
13
|
-
import consola from 'consola';
|
|
14
|
-
import type { Plugin, UserConfig, ProxyOptions } from 'vite';
|
|
15
|
-
import { getCheckerModule, getHandlebarsModule, getViteModule } from './vite.js';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* There seems to be various documented issues using Vite in a monorepo setup that are impacted by various factors.
|
|
19
|
-
*
|
|
20
|
-
* Consider:
|
|
21
|
-
* - npm workspace / lerna managed package links within the monorepo itself
|
|
22
|
-
* - installed package dependencies that have internal dependencies (peer or otherwise) back onto the packages in this monorepo
|
|
23
|
-
* - manually npm linked package dependencies that have internal (peer or otherwise) back onto the packages in this monorepo
|
|
24
|
-
*
|
|
25
|
-
* There are several layers of Vite configuration offered to try and combat this, but there doesn't seem to be a definitive guide.
|
|
26
|
-
*
|
|
27
|
-
* We've attempted to address the issue using optimizeDeps.include/exclude, resolve.dedupe, but there are several other
|
|
28
|
-
* configs like build.commonjsOptions.include/exclude etc.
|
|
29
|
-
*
|
|
30
|
-
* Devs can continue to use the default Vite based dev task where speed of reload is desired:
|
|
31
|
-
*
|
|
32
|
-
* `"dev": "genx dev"`
|
|
33
|
-
*
|
|
34
|
-
* ...but be aware of that the integrity of the dependency graph is being compromised to simply improve build speeds.
|
|
35
|
-
* You may wish to use webpack for development instead, especially if using npm link.
|
|
36
|
-
*
|
|
37
|
-
* `"dev:webpack": "genx dev -b webpack"`
|
|
38
|
-
*
|
|
39
|
-
* This has the added benefit of aligning with the current production app builds.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
export default async (ctx: BuildContext) => {
|
|
43
|
-
const {
|
|
44
|
-
config: {
|
|
45
|
-
app: { rootElement },
|
|
46
|
-
env,
|
|
47
|
-
http,
|
|
48
|
-
},
|
|
49
|
-
dirs: { cwd },
|
|
50
|
-
cli: {
|
|
51
|
-
isDev,
|
|
52
|
-
isBuild,
|
|
53
|
-
isAnalyze,
|
|
54
|
-
options: { open, https },
|
|
55
|
-
},
|
|
56
|
-
pkg: { description },
|
|
57
|
-
resolve: { alias },
|
|
58
|
-
} = ctx;
|
|
59
|
-
|
|
60
|
-
const define = resolveDefineConfig(env, http, 'vite');
|
|
61
|
-
const handlebars = await getHandlebarsModule();
|
|
62
|
-
const vite = await getViteModule();
|
|
63
|
-
|
|
64
|
-
const publicPath = getPublicPath();
|
|
65
|
-
|
|
66
|
-
const tsconfigPath = resolve(cwd, 'tsconfig.json');
|
|
67
|
-
const buildMode = ctx.config.vite?.checker?.buildMode ?? false;
|
|
68
|
-
const checkerPlugin = existsSync(tsconfigPath)
|
|
69
|
-
? (await getCheckerModule())({
|
|
70
|
-
typescript: { tsconfigPath, buildMode },
|
|
71
|
-
})
|
|
72
|
-
: null;
|
|
73
|
-
|
|
74
|
-
const baseHrefPlugin: Plugin = {
|
|
75
|
-
name: 'genesis-base-href',
|
|
76
|
-
transformIndexHtml(html) {
|
|
77
|
-
if (html.includes('<base')) return html;
|
|
78
|
-
return html.replace('<head>', `<head>\n <base href="${publicPath}" />`);
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const config: UserConfig = {
|
|
83
|
-
plugins: [
|
|
84
|
-
baseHrefPlugin,
|
|
85
|
-
...(checkerPlugin ? [checkerPlugin] : []),
|
|
86
|
-
handlebars({
|
|
87
|
-
context: {
|
|
88
|
-
// Template is shared with Webpack HTML plugin, which expects the data structure below
|
|
89
|
-
htmlWebpackPlugin: {
|
|
90
|
-
options: {
|
|
91
|
-
customElementTagName: rootElement,
|
|
92
|
-
title: description,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
insertEntryPoint: true,
|
|
96
|
-
},
|
|
97
|
-
}) as unknown as Plugin,
|
|
98
|
-
],
|
|
99
|
-
resolve: {
|
|
100
|
-
alias: {
|
|
101
|
-
...alias,
|
|
102
|
-
'foundationZero/ZeroDesignSystem': '@genesislcap/foundation-zero',
|
|
103
|
-
'foundationRapid/RapidDesignSystem': '@genesislcap/rapid-design-system',
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* A side effect of using npm linked packages like `@genesislcap/pbc-reporting` in Vite, seems to be that it will
|
|
107
|
-
* allow these to keep their own dependency graph, even though we may specify these as peerDependencies, which
|
|
108
|
-
* isn't what we want. We want our `@genesislcap/*` linked packages to be treated like they are part of this
|
|
109
|
-
* monorepo, so we need to force the inclusion of any common dependencies shared.
|
|
110
|
-
*
|
|
111
|
-
* Globs aren't supported.
|
|
112
|
-
*/
|
|
113
|
-
dedupe: [
|
|
114
|
-
'@genesislcap/design-system-configurator',
|
|
115
|
-
'@genesislcap/documentation-components',
|
|
116
|
-
'@genesislcap/foundation-alerts',
|
|
117
|
-
'@genesislcap/foundation-auth',
|
|
118
|
-
'@genesislcap/foundation-comms',
|
|
119
|
-
'@genesislcap/foundation-criteria',
|
|
120
|
-
'@genesislcap/foundation-entity-management',
|
|
121
|
-
'@genesislcap/foundation-errors',
|
|
122
|
-
'@genesislcap/foundation-events',
|
|
123
|
-
'@genesislcap/foundation-filters',
|
|
124
|
-
'@genesislcap/foundation-forms',
|
|
125
|
-
'@genesislcap/foundation-header',
|
|
126
|
-
'@genesislcap/foundation-i18n',
|
|
127
|
-
'@genesislcap/foundation-inbox',
|
|
128
|
-
'@genesislcap/foundation-layout',
|
|
129
|
-
'@genesislcap/foundation-logger',
|
|
130
|
-
'@genesislcap/foundation-notification-dashboard',
|
|
131
|
-
'@genesislcap/foundation-notifications',
|
|
132
|
-
'@genesislcap/foundation-progress-overlay',
|
|
133
|
-
'@genesislcap/foundation-reporting',
|
|
134
|
-
'@genesislcap/foundation-settings',
|
|
135
|
-
'@genesislcap/foundation-shell',
|
|
136
|
-
'@genesislcap/foundation-state-machine',
|
|
137
|
-
'@genesislcap/foundation-store',
|
|
138
|
-
'@genesislcap/foundation-ui',
|
|
139
|
-
'@genesislcap/foundation-utils',
|
|
140
|
-
'@genesislcap/foundation-zero',
|
|
141
|
-
'@genesislcap/foundation-zero-grid-next',
|
|
142
|
-
'@genesislcap/foundation-zero-grid-pro',
|
|
143
|
-
'@genesislcap/foundation-zero-grid-tabulator',
|
|
144
|
-
'@genesislcap/g2plot-chart',
|
|
145
|
-
'@genesislcap/grid-next',
|
|
146
|
-
'@genesislcap/grid-pro',
|
|
147
|
-
'@genesislcap/grid-tabulator',
|
|
148
|
-
'@genesislcap/pbc-auth',
|
|
149
|
-
'@genesislcap/pbc-notify',
|
|
150
|
-
'@genesislcap/pbc-reporting',
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
define,
|
|
154
|
-
build: {
|
|
155
|
-
minify: false,
|
|
156
|
-
lib: isDev
|
|
157
|
-
? {
|
|
158
|
-
entry: 'src/index.ts',
|
|
159
|
-
formats: ['es'],
|
|
160
|
-
}
|
|
161
|
-
: undefined,
|
|
162
|
-
},
|
|
163
|
-
root: cwd,
|
|
164
|
-
optimizeDeps: {
|
|
165
|
-
/**
|
|
166
|
-
* Any external @genesislcap packages, ie. not contained within this monorepo, vite will optimize by default.
|
|
167
|
-
* This behaviour creates core @genesislcap and possibly @microsoft library duplication issues. To address this,
|
|
168
|
-
* we need to explicitly exclude these external @genesislcap packages from the optimisation process/cache. This
|
|
169
|
-
* ensures they are built like the rest of the core @genesislcap packages, all using the one copy of common libs.
|
|
170
|
-
*
|
|
171
|
-
* Note: Globs don't seem to work here, but the docs seem to suggest they do.
|
|
172
|
-
*/
|
|
173
|
-
exclude: ['@genesislcap/pbc-auth', '@genesislcap/pbc-reporting'],
|
|
174
|
-
/**
|
|
175
|
-
* The @genesis-community/golden-layout repo does not depend on the @genesislcap or @microsoft packages,
|
|
176
|
-
* so it is safe to include here, which is the default behaviour. Leaving this explicit 'include' here for future
|
|
177
|
-
* reference, should we convert the above to a glob.
|
|
178
|
-
*/
|
|
179
|
-
include: ['@genesis-community/golden-layout'],
|
|
180
|
-
},
|
|
181
|
-
base: publicPath,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
if (!existsSync(resolve(cwd, 'index.html'))) {
|
|
185
|
-
consola.warn('index.html file not found - copying default one.');
|
|
186
|
-
const copyfiles = await resolveBin('copyfiles');
|
|
187
|
-
const index = relative(cwd, resolve(__dirname, '../public/index.html'));
|
|
188
|
-
run(cwd, `${copyfiles} --flat ${index} .`);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (isDev) {
|
|
192
|
-
const server = await vite.createServer({
|
|
193
|
-
...config,
|
|
194
|
-
configFile: false,
|
|
195
|
-
server: {
|
|
196
|
-
open,
|
|
197
|
-
host: '0.0.0.0',
|
|
198
|
-
port: getPort(ctx.pkg),
|
|
199
|
-
proxy: createDevProxies() as Record<string, ProxyOptions>,
|
|
200
|
-
https: https ? getDevCertOptions() : undefined,
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
await server.listen();
|
|
204
|
-
server.printUrls();
|
|
205
|
-
} else if (isBuild) {
|
|
206
|
-
await vite.build(config);
|
|
207
|
-
} else if (isAnalyze) {
|
|
208
|
-
throw new Error(`vite builder - analyze support not implemented yet`);
|
|
209
|
-
} else {
|
|
210
|
-
throw new Error(`Unrecognized command: ${JSON.stringify(ctx.cli.options)}`);
|
|
211
|
-
}
|
|
212
|
-
};
|
package/src/vite.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* This is a glue layer to import the ESM modules into the commonjs plugin.
|
|
5
|
-
*
|
|
6
|
-
* 1. We want to use dynamic import function to import the esm module in.
|
|
7
|
-
* 2. `tsc` will transpile `import()` calls to `require()` calls for the tsconfig settings we need, which we do not want.
|
|
8
|
-
* 3. We use an obfuscated call to the `import()` function via the function constructor to work around this.
|
|
9
|
-
*/
|
|
10
|
-
const dynamicImport = new Function('specifier', 'return import(specifier)');
|
|
11
|
-
|
|
12
|
-
export const getHandlebarsModule = async () =>
|
|
13
|
-
(await dynamicImport('vite-plugin-handlebars')).default as (...args: any) => Promise<Plugin>;
|
|
14
|
-
|
|
15
|
-
export const getCheckerModule = async () =>
|
|
16
|
-
(await dynamicImport('vite-plugin-checker')).default as (...args: any) => Plugin;
|
|
17
|
-
|
|
18
|
-
export const getViteModule = async () => {
|
|
19
|
-
const vite = await dynamicImport('vite');
|
|
20
|
-
return {
|
|
21
|
-
build: vite.build,
|
|
22
|
-
createServer: vite.createServer,
|
|
23
|
-
};
|
|
24
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"declarationDir": "./dist",
|
|
5
|
-
"lib": ["ES2015", "ES2016", "ES2017", "ES2019"],
|
|
6
|
-
"module": "commonjs",
|
|
7
|
-
"outDir": "./dist",
|
|
8
|
-
"rootDir": "./src",
|
|
9
|
-
"types": ["vite/client"]
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*"]
|
|
12
|
-
}
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts","./src/vite.ts"],"version":"5.9.2"}
|