@jahia/vite-plugin 0.5.5 → 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 +6 -15
- package/package.json +2 -2
- package/pom.xml +1 -1
- package/src/index.ts +2 -6
- package/src/insert-filename.ts +8 -8
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import multiEntry from '@rollup/plugin-multi-entry';
|
|
2
|
-
import 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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
|
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.
|
|
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.
|
|
30
|
+
"rollup": "^4.35.0",
|
|
31
31
|
"vite": "^6.1.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
package/pom.xml
CHANGED
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
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
async closeBundle() {
|
|
22
|
-
if (succeeded) await callback();
|
|
17
|
+
async closeBundle(error) {
|
|
18
|
+
if (!error) await callback();
|
|
23
19
|
},
|
|
24
20
|
};
|
|
25
21
|
}
|
package/src/insert-filename.ts
CHANGED
|
@@ -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
|
-
|
|
69
|
-
...node.declaration,
|
|
70
|
-
|
|
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 }
|