@jahia/vite-plugin 0.5.4 → 0.5.6

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/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import multiEntry from '@rollup/plugin-multi-entry';
2
- import path$1 from 'node:path';
2
+ import path from 'node:path';
3
3
  import { styleText } from 'node:util';
4
4
  import { globSync } from 'tinyglobby';
5
5
  import { print } from 'esrap';
6
6
  import { walk } from 'zimmerframe';
7
7
  import { createFilter } from '@rollup/pluginutils';
8
- import path from 'path';
9
8
 
10
9
  var sharedLibs = {
11
10
  // React ships as CJS, so we need our own shims
@@ -29,7 +28,6 @@ const insertFilename = (root, prefix) => {
29
28
  const ast = walk(this.parse(code), null, {
30
29
  // Only target `export default function`
31
30
  ExportDefaultDeclaration(node) {
32
- if (node.declaration.type !== "FunctionDeclaration") return;
33
31
  return {
34
32
  // export default
35
33
  type: "ExportDefaultDeclaration",
@@ -49,11 +47,8 @@ const insertFilename = (root, prefix) => {
49
47
  property: { type: "Identifier", name: "defineProperty" }
50
48
  },
51
49
  arguments: [
52
- {
53
- // Original function
54
- ...node.declaration,
55
- type: "FunctionExpression"
56
- },
50
+ // Convert function and class declarations to expressions, keep others as is
51
+ node.declaration.type === "FunctionDeclaration" ? { ...node.declaration, type: "FunctionExpression" } : node.declaration.type === "ClassDeclaration" ? { ...node.declaration, type: "ClassExpression" } : node.declaration,
57
52
  { type: "Literal", value: "__filename" },
58
53
  {
59
54
  // { value: id, enumerable: false }
@@ -91,14 +86,10 @@ const insertFilename = (root, prefix) => {
91
86
 
92
87
  const external = Object.keys(sharedLibs);
93
88
  function buildSuccessPlugin(callback) {
94
- let succeeded = true;
95
89
  return {
96
90
  name: "build-success-callback",
97
- buildEnd(error) {
98
- succeeded = !error;
99
- },
100
- async closeBundle() {
101
- if (succeeded) await callback();
91
+ async closeBundle(error) {
92
+ if (!error) await callback();
102
93
  }
103
94
  };
104
95
  }
@@ -137,7 +128,7 @@ function jahia(options = {}) {
137
128
  build: {
138
129
  lib: {
139
130
  entry: Object.fromEntries(
140
- clientEntries.map((file) => [file, path$1.join(clientBaseDir, file)])
131
+ clientEntries.map((file) => [file, path.join(clientBaseDir, file)])
141
132
  ),
142
133
  formats: ["es"]
143
134
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/vite-plugin",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com:Jahia/javascript-modules.git",
@@ -27,7 +27,7 @@
27
27
  "@types/node": "^22.13.5",
28
28
  "pkgroll": "^2.11.0",
29
29
  "publint": "^0.3.6",
30
- "rollup": "^4.34.8",
30
+ "rollup": "^4.35.0",
31
31
  "vite": "^6.1.1"
32
32
  },
33
33
  "peerDependencies": {
package/pom.xml CHANGED
@@ -3,7 +3,7 @@
3
3
  <parent>
4
4
  <artifactId>javascript-modules</artifactId>
5
5
  <groupId>org.jahia.modules</groupId>
6
- <version>0.5.4</version>
6
+ <version>0.5.6</version>
7
7
  </parent>
8
8
  <artifactId>vite-plugin</artifactId>
9
9
  <name>Vite plugin for Jahia</name>
@@ -68,13 +68,13 @@
68
68
  <executions>
69
69
  <!-- Keep the package.json in sync with the maven version -->
70
70
  <execution>
71
- <id>bump-version</id>
71
+ <id>sync-version</id>
72
72
  <phase>process-resources</phase>
73
73
  <goals>
74
74
  <goal>yarn</goal>
75
75
  </goals>
76
76
  <configuration>
77
- <arguments>node sync-version.js ${project.version}</arguments>
77
+ <arguments>node ../.m2/sync-version.js ${project.version}</arguments>
78
78
  </configuration>
79
79
  </execution>
80
80
  </executions>
package/src/index.ts CHANGED
@@ -12,14 +12,10 @@ const external = Object.keys(sharedLibs);
12
12
 
13
13
  /** Plugin to execute a callback when a build succeeds. */
14
14
  function buildSuccessPlugin(callback: () => void | Promise<void>): Plugin {
15
- let succeeded = true;
16
15
  return {
17
16
  name: "build-success-callback",
18
- buildEnd(error) {
19
- succeeded = !error;
20
- },
21
- async closeBundle() {
22
- if (succeeded) await callback();
17
+ async closeBundle(error) {
18
+ if (!error) await callback();
23
19
  },
24
20
  };
25
21
  }
@@ -1,9 +1,9 @@
1
1
  import { print } from "esrap";
2
2
  import type { Node } from "estree";
3
- import { Plugin } from "rollup";
3
+ import type { Plugin } from "rollup";
4
4
  import { walk } from "zimmerframe";
5
5
  import { createFilter } from "@rollup/pluginutils";
6
- import path from "path";
6
+ import path from "node:path";
7
7
 
8
8
  /**
9
9
  * This plugin adds a `__filename` property to all default exports.
@@ -44,7 +44,6 @@ export const insertFilename = (root: string, prefix: string): Plugin => {
44
44
  const ast = walk(this.parse(code) as Node, null, {
45
45
  // Only target `export default function`
46
46
  ExportDefaultDeclaration(node) {
47
- if (node.declaration.type !== "FunctionDeclaration") return;
48
47
  return {
49
48
  // export default
50
49
  type: "ExportDefaultDeclaration",
@@ -64,11 +63,12 @@ export const insertFilename = (root: string, prefix: string): Plugin => {
64
63
  property: { type: "Identifier", name: "defineProperty" },
65
64
  },
66
65
  arguments: [
67
- {
68
- // Original function
69
- ...node.declaration,
70
- type: "FunctionExpression",
71
- },
66
+ // Convert function and class declarations to expressions, keep others as is
67
+ node.declaration.type === "FunctionDeclaration"
68
+ ? { ...node.declaration, type: "FunctionExpression" }
69
+ : node.declaration.type === "ClassDeclaration"
70
+ ? { ...node.declaration, type: "ClassExpression" }
71
+ : node.declaration,
72
72
  { type: "Literal", value: "__filename" },
73
73
  {
74
74
  // { value: id, enumerable: false }
package/sync-version.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * @module
3
- *
4
- * Updates the package.json version, used during the maven release process.
5
- *
6
- * Usage: node sync-version.js 1.2.3
7
- *
8
- * @see {@link ./pom.xml}
9
- */
10
-
11
- import fs from "node:fs";
12
-
13
- const updated = fs
14
- .readFileSync("package.json", "utf8")
15
- .replace(/"version": ".+"/, `"version": ${JSON.stringify(process.argv[2])}`);
16
- fs.writeFileSync("package.json", updated);