@navita/vite-plugin 2.0.4 → 2.1.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.
- package/index.cjs +2 -2
- package/index.mjs +2 -2
- package/package.json +7 -2
- package/remix.cjs +1 -1
- package/remix.mjs +1 -1
- package/rwsdk.cjs +96 -0
- package/rwsdk.d.ts +7 -0
- package/rwsdk.mjs +74 -0
package/index.cjs
CHANGED
|
@@ -74,7 +74,7 @@ function navita(options) {
|
|
|
74
74
|
renderer.clearCache(id);
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
|
-
const { result
|
|
77
|
+
const { result, sourceMap, dependencies } = await renderer.transformAndProcess({
|
|
78
78
|
content: code,
|
|
79
79
|
filePath: id
|
|
80
80
|
});
|
|
@@ -126,7 +126,7 @@ function navita(options) {
|
|
|
126
126
|
}
|
|
127
127
|
clearTimeout(updateTimer);
|
|
128
128
|
updateTimer = setTimeout(()=>{
|
|
129
|
-
const { moduleGraph
|
|
129
|
+
const { moduleGraph, ws } = server;
|
|
130
130
|
const mod = moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULE_ID);
|
|
131
131
|
if (mod) {
|
|
132
132
|
moduleGraph.invalidateModule(mod);
|
package/index.mjs
CHANGED
|
@@ -72,7 +72,7 @@ function navita(options) {
|
|
|
72
72
|
renderer.clearCache(id);
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
|
-
const { result
|
|
75
|
+
const { result, sourceMap, dependencies } = await renderer.transformAndProcess({
|
|
76
76
|
content: code,
|
|
77
77
|
filePath: id
|
|
78
78
|
});
|
|
@@ -124,7 +124,7 @@ function navita(options) {
|
|
|
124
124
|
}
|
|
125
125
|
clearTimeout(updateTimer);
|
|
126
126
|
updateTimer = setTimeout(()=>{
|
|
127
|
-
const { moduleGraph
|
|
127
|
+
const { moduleGraph, ws } = server;
|
|
128
128
|
const mod = moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULE_ID);
|
|
129
129
|
if (mod) {
|
|
130
130
|
moduleGraph.invalidateModule(mod);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navita/vite-plugin",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Navita Vite Plugin",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vite",
|
|
@@ -19,11 +19,16 @@
|
|
|
19
19
|
"import": "./remix.mjs",
|
|
20
20
|
"require": "./remix.cjs",
|
|
21
21
|
"types": "./remix.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./rwsdk": {
|
|
24
|
+
"import": "./rwsdk.mjs",
|
|
25
|
+
"require": "./rwsdk.cjs",
|
|
26
|
+
"types": "./rwsdk.d.ts"
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
"dependencies": {
|
|
25
30
|
"@navita/core": "1.0.1",
|
|
26
|
-
"@navita/css": "0.2.
|
|
31
|
+
"@navita/css": "0.2.1"
|
|
27
32
|
},
|
|
28
33
|
"license": "MIT",
|
|
29
34
|
"author": "Eagerpatch",
|
package/remix.cjs
CHANGED
|
@@ -30,7 +30,7 @@ let cssFileName;
|
|
|
30
30
|
function navitaRemix(options) {
|
|
31
31
|
let isProduction = false;
|
|
32
32
|
let hasEmittedCss = false;
|
|
33
|
-
const { renderChunk
|
|
33
|
+
const { renderChunk, ...navitaVite } = index.navita(options);
|
|
34
34
|
return [
|
|
35
35
|
navitaVite,
|
|
36
36
|
{
|
package/remix.mjs
CHANGED
package/rwsdk.cjs
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fsp = require('node:fs/promises');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
var index = require('./index.cjs');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var fsp__namespace = /*#__PURE__*/_interopNamespaceDefault(fsp);
|
|
25
|
+
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
26
|
+
|
|
27
|
+
function navitaRwsdk(options) {
|
|
28
|
+
let projectRootDir;
|
|
29
|
+
let base;
|
|
30
|
+
const navitaPlugin = index.navita(options);
|
|
31
|
+
return [
|
|
32
|
+
navitaPlugin,
|
|
33
|
+
{
|
|
34
|
+
name: "navita-rwsdk",
|
|
35
|
+
enforce: "post",
|
|
36
|
+
configResolved (config) {
|
|
37
|
+
projectRootDir = config.root;
|
|
38
|
+
base = config.base;
|
|
39
|
+
},
|
|
40
|
+
async renderChunk (code) {
|
|
41
|
+
// Only run during the linker pass on the worker environment
|
|
42
|
+
// @ts-expect-error - environment exists at runtime in Vite 6+
|
|
43
|
+
const environmentName = this.environment?.name;
|
|
44
|
+
if (environmentName !== "worker" || process.env.RWSDK_BUILD_PASS !== "linker") {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
// Read the client manifest to find the navita CSS path
|
|
48
|
+
const manifestPath = path__namespace.resolve(projectRootDir, "dist", "client", ".vite", "manifest.json");
|
|
49
|
+
let manifestContent;
|
|
50
|
+
try {
|
|
51
|
+
manifestContent = await fsp__namespace.readFile(manifestPath, "utf-8");
|
|
52
|
+
} catch {
|
|
53
|
+
console.warn("[navita-rwsdk] Could not read client manifest, skipping CSS replacement");
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const manifest = JSON.parse(manifestContent);
|
|
57
|
+
// Find the navita CSS file in the manifest
|
|
58
|
+
let navitaCssPath = null;
|
|
59
|
+
for (const [key, value] of Object.entries(manifest)){
|
|
60
|
+
// Check if this is the navita CSS entry directly
|
|
61
|
+
if (key.includes("navita") && key.endsWith(".css")) {
|
|
62
|
+
navitaCssPath = (base || "/") + value.file;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
// Also check if it's referenced in the css array of any entry
|
|
66
|
+
if (value.css) {
|
|
67
|
+
for (const cssFile of value.css){
|
|
68
|
+
if (cssFile.includes("navita")) {
|
|
69
|
+
navitaCssPath = (base || "/") + cssFile;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (navitaCssPath) break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!navitaCssPath) {
|
|
77
|
+
console.warn("[navita-rwsdk] Could not find navita CSS in manifest");
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
// Replace virtual:navita.css references with the actual hashed path
|
|
81
|
+
let newCode = code;
|
|
82
|
+
newCode = newCode.replaceAll(`/${index.VIRTUAL_MODULE_ID}`, navitaCssPath);
|
|
83
|
+
newCode = newCode.replaceAll(index.VIRTUAL_MODULE_ID, navitaCssPath);
|
|
84
|
+
if (newCode !== code) {
|
|
85
|
+
return {
|
|
86
|
+
code: newCode,
|
|
87
|
+
map: null
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
exports.navitaRwsdk = navitaRwsdk;
|
package/rwsdk.d.ts
ADDED
package/rwsdk.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as fsp from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { navita, VIRTUAL_MODULE_ID } from './index.mjs';
|
|
4
|
+
|
|
5
|
+
function navitaRwsdk(options) {
|
|
6
|
+
let projectRootDir;
|
|
7
|
+
let base;
|
|
8
|
+
const navitaPlugin = navita(options);
|
|
9
|
+
return [
|
|
10
|
+
navitaPlugin,
|
|
11
|
+
{
|
|
12
|
+
name: "navita-rwsdk",
|
|
13
|
+
enforce: "post",
|
|
14
|
+
configResolved (config) {
|
|
15
|
+
projectRootDir = config.root;
|
|
16
|
+
base = config.base;
|
|
17
|
+
},
|
|
18
|
+
async renderChunk (code) {
|
|
19
|
+
// Only run during the linker pass on the worker environment
|
|
20
|
+
// @ts-expect-error - environment exists at runtime in Vite 6+
|
|
21
|
+
const environmentName = this.environment?.name;
|
|
22
|
+
if (environmentName !== "worker" || process.env.RWSDK_BUILD_PASS !== "linker") {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// Read the client manifest to find the navita CSS path
|
|
26
|
+
const manifestPath = path.resolve(projectRootDir, "dist", "client", ".vite", "manifest.json");
|
|
27
|
+
let manifestContent;
|
|
28
|
+
try {
|
|
29
|
+
manifestContent = await fsp.readFile(manifestPath, "utf-8");
|
|
30
|
+
} catch {
|
|
31
|
+
console.warn("[navita-rwsdk] Could not read client manifest, skipping CSS replacement");
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const manifest = JSON.parse(manifestContent);
|
|
35
|
+
// Find the navita CSS file in the manifest
|
|
36
|
+
let navitaCssPath = null;
|
|
37
|
+
for (const [key, value] of Object.entries(manifest)){
|
|
38
|
+
// Check if this is the navita CSS entry directly
|
|
39
|
+
if (key.includes("navita") && key.endsWith(".css")) {
|
|
40
|
+
navitaCssPath = (base || "/") + value.file;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
// Also check if it's referenced in the css array of any entry
|
|
44
|
+
if (value.css) {
|
|
45
|
+
for (const cssFile of value.css){
|
|
46
|
+
if (cssFile.includes("navita")) {
|
|
47
|
+
navitaCssPath = (base || "/") + cssFile;
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (navitaCssPath) break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (!navitaCssPath) {
|
|
55
|
+
console.warn("[navita-rwsdk] Could not find navita CSS in manifest");
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
// Replace virtual:navita.css references with the actual hashed path
|
|
59
|
+
let newCode = code;
|
|
60
|
+
newCode = newCode.replaceAll(`/${VIRTUAL_MODULE_ID}`, navitaCssPath);
|
|
61
|
+
newCode = newCode.replaceAll(VIRTUAL_MODULE_ID, navitaCssPath);
|
|
62
|
+
if (newCode !== code) {
|
|
63
|
+
return {
|
|
64
|
+
code: newCode,
|
|
65
|
+
map: null
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { navitaRwsdk };
|