@navita/vite-plugin 2.0.3 → 2.0.5

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 CHANGED
@@ -74,7 +74,7 @@ function navita(options) {
74
74
  renderer.clearCache(id);
75
75
  return null;
76
76
  }
77
- const { result , sourceMap , dependencies } = await renderer.transformAndProcess({
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 , ws } = server;
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 , sourceMap , dependencies } = await renderer.transformAndProcess({
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 , ws } = server;
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",
3
+ "version": "2.0.5",
4
4
  "description": "Navita Vite Plugin",
5
5
  "keywords": [
6
6
  "vite",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@navita/core": "1.0.1",
26
- "@navita/css": "0.2.0"
26
+ "@navita/css": "0.2.1"
27
27
  },
28
28
  "license": "MIT",
29
29
  "author": "Eagerpatch",
package/remix.cjs CHANGED
@@ -22,12 +22,15 @@ function _interopNamespaceDefault(e) {
22
22
 
23
23
  var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
24
24
 
25
- const remixServerBuildId = '\0virtual:remix/server-build';
25
+ const VIRTUAL_MODULE_IDS = [
26
+ '\0virtual:remix/server-build',
27
+ '\0virtual:react-router/server-build'
28
+ ];
26
29
  let cssFileName;
27
30
  function navitaRemix(options) {
28
31
  let isProduction = false;
29
32
  let hasEmittedCss = false;
30
- const { renderChunk , ...navitaVite } = index.navita(options);
33
+ const { renderChunk, ...navitaVite } = index.navita(options);
31
34
  return [
32
35
  navitaVite,
33
36
  {
@@ -36,10 +39,10 @@ function navitaRemix(options) {
36
39
  isProduction = config.mode === 'production';
37
40
  },
38
41
  transform (code, id) {
39
- if (isProduction || id !== remixServerBuildId) {
42
+ if (isProduction || !VIRTUAL_MODULE_IDS.includes(id)) {
40
43
  return;
41
44
  }
42
- return `${code}\n${remixServerBuildExtension}`;
45
+ return `${code}\n${SERVER_BUILD_EXTENSION}`;
43
46
  },
44
47
  renderChunk (_, chunk, options) {
45
48
  const isServerChunk = options.dir.endsWith('/server');
@@ -56,7 +59,7 @@ function navitaRemix(options) {
56
59
  }
57
60
  if (isServerChunk && !hasEmittedCss) {
58
61
  // In the server-build, we'll generate the CSS and emit it as an asset.
59
- // Remix will then move it to the client assets.
62
+ // Remix/react-router will then move it to the client assets.
60
63
  this.emitFile({
61
64
  fileName: cssFileName,
62
65
  name: 'navita.css',
@@ -69,7 +72,7 @@ function navitaRemix(options) {
69
72
  }
70
73
  ];
71
74
  }
72
- const remixServerBuildExtension = `
75
+ const SERVER_BUILD_EXTENSION = `
73
76
  routes.root.module = {
74
77
  ...route0,
75
78
  links: () => [
package/remix.mjs CHANGED
@@ -1,12 +1,15 @@
1
1
  import * as crypto from 'node:crypto';
2
2
  import { navita, getRenderer, VIRTUAL_MODULE_ID } from './index.mjs';
3
3
 
4
- const remixServerBuildId = '\0virtual:remix/server-build';
4
+ const VIRTUAL_MODULE_IDS = [
5
+ '\0virtual:remix/server-build',
6
+ '\0virtual:react-router/server-build'
7
+ ];
5
8
  let cssFileName;
6
9
  function navitaRemix(options) {
7
10
  let isProduction = false;
8
11
  let hasEmittedCss = false;
9
- const { renderChunk , ...navitaVite } = navita(options);
12
+ const { renderChunk, ...navitaVite } = navita(options);
10
13
  return [
11
14
  navitaVite,
12
15
  {
@@ -15,10 +18,10 @@ function navitaRemix(options) {
15
18
  isProduction = config.mode === 'production';
16
19
  },
17
20
  transform (code, id) {
18
- if (isProduction || id !== remixServerBuildId) {
21
+ if (isProduction || !VIRTUAL_MODULE_IDS.includes(id)) {
19
22
  return;
20
23
  }
21
- return `${code}\n${remixServerBuildExtension}`;
24
+ return `${code}\n${SERVER_BUILD_EXTENSION}`;
22
25
  },
23
26
  renderChunk (_, chunk, options) {
24
27
  const isServerChunk = options.dir.endsWith('/server');
@@ -35,7 +38,7 @@ function navitaRemix(options) {
35
38
  }
36
39
  if (isServerChunk && !hasEmittedCss) {
37
40
  // In the server-build, we'll generate the CSS and emit it as an asset.
38
- // Remix will then move it to the client assets.
41
+ // Remix/react-router will then move it to the client assets.
39
42
  this.emitFile({
40
43
  fileName: cssFileName,
41
44
  name: 'navita.css',
@@ -48,7 +51,7 @@ function navitaRemix(options) {
48
51
  }
49
52
  ];
50
53
  }
51
- const remixServerBuildExtension = `
54
+ const SERVER_BUILD_EXTENSION = `
52
55
  routes.root.module = {
53
56
  ...route0,
54
57
  links: () => [