@navita/vite-plugin 3.0.0-next.1 → 3.0.0-next.2

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
@@ -9,6 +9,8 @@ const VIRTUAL_MODULE_ID = "virtual:navita.css";
9
9
  const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID.replace(/.css$/, "")}`;
10
10
  function navita(options) {
11
11
  const importMap = [..._navita_css.importMap, ...options?.importMap || []];
12
+ const transformNodeModules = options?.transformNodeModules || [];
13
+ const isForcedNodeModule = (id) => transformNodeModules.some((matcher) => matcher instanceof RegExp ? matcher.test(id) : id.includes(matcher));
12
14
  let server;
13
15
  let config;
14
16
  let updateTimer = null;
@@ -34,6 +36,7 @@ function navita(options) {
34
36
  ...options?.engineOptions || {}
35
37
  },
36
38
  importMap,
39
+ transformNodeModules,
37
40
  resolver: async (filepath, request) => {
38
41
  return (await this.resolve(request, filepath))?.id || null;
39
42
  },
@@ -55,7 +58,7 @@ function navita(options) {
55
58
  },
56
59
  async transform(code, id) {
57
60
  const renderer = getRenderer();
58
- if (!renderer || id.includes("node_modules") || process.env.RWSDK_BUILD_PASS === "linker") return null;
61
+ if (!renderer || id.includes("node_modules") && !isForcedNodeModule(id) || process.env.RWSDK_BUILD_PASS === "linker") return null;
59
62
  if (!importMap.map((x) => x.source).some((value) => code.indexOf(value) !== -1)) {
60
63
  renderer.clearCache(id);
61
64
  return null;
package/index.d.ts CHANGED
@@ -6,6 +6,25 @@ declare const VIRTUAL_MODULE_ID = "virtual:navita.css";
6
6
  interface Options {
7
7
  importMap?: ImportMap;
8
8
  engineOptions?: EngineOptions;
9
+ /**
10
+ * By default the transform skips every file under `node_modules`, since most
11
+ * dependencies ship plain CSS or no navita styles at all. A component library
12
+ * authored WITH navita, however, ships un-compiled `style()` calls that must
13
+ * still be transformed — otherwise they throw "Could not find an adapter" at
14
+ * runtime.
15
+ *
16
+ * Provide matchers here for the `node_modules` paths that should be treated
17
+ * as navita source. Each matcher is a substring (matched with
18
+ * `id.includes(...)`) or a `RegExp` tested against the module id. A matched
19
+ * path is both transformed AND recursively evaluated, so the library's own
20
+ * cross-file imports (a theme/tokens file it ships) resolve correctly instead
21
+ * of being imported as an opaque module. navita's own packages (`@navita/*`)
22
+ * stay external regardless.
23
+ *
24
+ * @example
25
+ * navita({ transformNodeModules: ["@acme/ui", /@acme\/.*\/navita\//] })
26
+ */
27
+ transformNodeModules?: (string | RegExp)[];
9
28
  }
10
29
  declare function navita(options?: Options): Plugin;
11
30
  declare function getRenderer(): Renderer | undefined;
package/index.mjs CHANGED
@@ -9,6 +9,8 @@ const VIRTUAL_MODULE_ID = "virtual:navita.css";
9
9
  const RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID.replace(/.css$/, "")}`;
10
10
  function navita(options) {
11
11
  const importMap$1 = [...importMap, ...options?.importMap || []];
12
+ const transformNodeModules = options?.transformNodeModules || [];
13
+ const isForcedNodeModule = (id) => transformNodeModules.some((matcher) => matcher instanceof RegExp ? matcher.test(id) : id.includes(matcher));
12
14
  let server;
13
15
  let config;
14
16
  let updateTimer = null;
@@ -34,6 +36,7 @@ function navita(options) {
34
36
  ...options?.engineOptions || {}
35
37
  },
36
38
  importMap: importMap$1,
39
+ transformNodeModules,
37
40
  resolver: async (filepath, request) => {
38
41
  return (await this.resolve(request, filepath))?.id || null;
39
42
  },
@@ -55,7 +58,7 @@ function navita(options) {
55
58
  },
56
59
  async transform(code, id) {
57
60
  const renderer = getRenderer();
58
- if (!renderer || id.includes("node_modules") || process.env.RWSDK_BUILD_PASS === "linker") return null;
61
+ if (!renderer || id.includes("node_modules") && !isForcedNodeModule(id) || process.env.RWSDK_BUILD_PASS === "linker") return null;
59
62
  if (!importMap$1.map((x) => x.source).some((value) => code.indexOf(value) !== -1)) {
60
63
  renderer.clearCache(id);
61
64
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navita/vite-plugin",
3
- "version": "3.0.0-next.1",
3
+ "version": "3.0.0-next.2",
4
4
  "description": "Navita Vite Plugin",
5
5
  "keywords": [
6
6
  "vite",
@@ -27,8 +27,8 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@navita/core": "3.0.0-next.1",
31
- "@navita/css": "3.0.0-next.1"
30
+ "@navita/core": "3.0.0-next.2",
31
+ "@navita/css": "3.0.0-next.2"
32
32
  },
33
33
  "license": "MIT",
34
34
  "author": "Eagerpatch",