@genesislcap/vite-builder 14.139.1 → 14.140.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'vite';
2
+ export declare const getHandlebarsModule: () => Promise<(...args: any) => Promise<Plugin>>;
3
+ //# sourceMappingURL=handlebars.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handlebars.d.ts","sourceRoot":"","sources":["../src/handlebars.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAW9B,eAAO,MAAM,mBAAmB,0BACuC,GAAG,KAAK,QAAQ,MAAM,CAAC,CAAA,CAAC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHandlebarsModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ /**
6
+ * This is a glue layer to import the ESM modules into the commonjs plugin.
7
+ *
8
+ * 1. We want to use dynamic import function to import the esm module in.
9
+ * 2. `tsc` will transpile `import()` calls to `require()` calls for the tsconfig settings we need, which we do not want.
10
+ * 3. We use an obfuscated call to the `import()` function via the function constructor to work around this.
11
+ */
12
+ const dynamicImport = new Function('specifier', 'return import(specifier)');
13
+ const getHandlebarsModule = () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return (yield dynamicImport('vite-plugin-handlebars')).default; });
14
+ exports.getHandlebarsModule = getHandlebarsModule;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;8BAEwB,YAAY;AAAvC,wBA+IE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAM3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;8BAEwB,YAAY;AAAvC,wBAiJE"}
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const build_kit_1 = require("@genesislcap/build-kit");
7
7
  const consola_1 = tslib_1.__importDefault(require("consola"));
8
8
  const vite_1 = require("vite");
9
- const vite_plugin_handlebars_1 = tslib_1.__importDefault(require("vite-plugin-handlebars"));
9
+ const handlebars_1 = require("./handlebars");
10
10
  /**
11
11
  * There seems to be various documented issues using Vite in a monorepo setup that are impacted by various factors.
12
12
  *
@@ -35,9 +35,10 @@ exports.default = (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* (
35
35
  var _a;
36
36
  const { config: { app: { rootElement }, env, http, }, dirs: { cwd }, cli: { isDev, isBuild, isAnalyze, options: { open }, }, pkg: { description }, resolve: { alias }, } = ctx;
37
37
  const define = (0, build_kit_1.resolveDefineConfig)(env, http, 'vite');
38
+ const handlebars = yield (0, handlebars_1.getHandlebarsModule)();
38
39
  const config = {
39
40
  plugins: [
40
- (0, vite_plugin_handlebars_1.default)({
41
+ handlebars({
41
42
  context: {
42
43
  // Template is shared with Webpack HTML plugin, which expects the data structure below
43
44
  htmlWebpackPlugin: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/vite-builder",
3
3
  "description": "Vite builder",
4
- "version": "14.139.1",
4
+ "version": "14.140.0",
5
5
  "license": "SEE LICENSE IN license.txt",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -14,12 +14,12 @@
14
14
  "dev": "tsc -b ./tsconfig.json -w"
15
15
  },
16
16
  "dependencies": {
17
- "@genesislcap/build-kit": "14.139.1",
17
+ "@genesislcap/build-kit": "14.140.0",
18
18
  "consola": "^3.0.2",
19
19
  "copyfiles": "^2.4.1",
20
20
  "tslib": "^2.3.1",
21
- "vite": "^4.4.12",
22
- "vite-plugin-handlebars": "^1.6.0"
21
+ "vite": "^4.5.2",
22
+ "vite-plugin-handlebars": "^2.0.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "rimraf": "^5.0.0",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "37c2db3914ae002405d21f0c8118727d92d0cc4b"
36
+ "gitHead": "219aed4b34d2df90cbf2003e9a4d84a8a627495e"
37
37
  }
@@ -0,0 +1,13 @@
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>;
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import type { BuildContext } from '@genesislcap/build-kit';
5
5
  import consola from 'consola';
6
6
  import { createServer } from 'vite';
7
7
  import type { UserConfig, Plugin } from 'vite';
8
- import handlebars from 'vite-plugin-handlebars';
8
+ import { getHandlebarsModule } from './handlebars';
9
9
 
10
10
  /**
11
11
  * There seems to be various documented issues using Vite in a monorepo setup that are impacted by various factors.
@@ -52,6 +52,8 @@ export default async (ctx: BuildContext) => {
52
52
 
53
53
  const define = resolveDefineConfig(env, http, 'vite');
54
54
 
55
+ const handlebars = await getHandlebarsModule();
56
+
55
57
  const config: UserConfig = {
56
58
  plugins: [
57
59
  handlebars({