react-cosmos-plugin-vite 6.0.0-beta.5 → 6.0.0-beta.7

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.
@@ -1,5 +1,5 @@
1
1
  import path from 'node:path';
2
- import { findUserModulePaths, generateUserImports, getPlaygroundUrl, } from 'react-cosmos';
2
+ import { findUserModulePaths, generateUserImports, getPlaygroundUrl, slash, } from 'react-cosmos';
3
3
  import { createViteRendererIndex } from './createViteRendererIndex.js';
4
4
  export const userImportsVirtualModuleId = 'virtual:cosmos-imports';
5
5
  export const userImportsResolvedModuleId = '\0' + userImportsVirtualModuleId;
@@ -34,8 +34,10 @@ export function reactCosmosViteRollupPlugin(cosmosConfig, cosmosViteConfig) {
34
34
  }
35
35
  },
36
36
  transform(src, id) {
37
- const isRendererIndex = cosmosViteConfig.indexPath
38
- ? cosmosViteConfig.indexPath === id
37
+ const absPath = cosmosViteConfig.indexPath &&
38
+ absoluteIndexPath(cosmosViteConfig.indexPath, cosmosConfig.rootDir);
39
+ const isRendererIndex = absPath
40
+ ? absPath === id
39
41
  : path.relative(cosmosConfig.rootDir, id).match(defaultIndexPattern);
40
42
  if (isRendererIndex) {
41
43
  const relPath = path.relative(process.cwd(), id);
@@ -51,3 +53,8 @@ export function reactCosmosViteRollupPlugin(cosmosConfig, cosmosViteConfig) {
51
53
  },
52
54
  };
53
55
  }
56
+ function absoluteIndexPath(indexPath, rootDir) {
57
+ return indexPath.startsWith(rootDir)
58
+ ? indexPath
59
+ : slash(path.join(rootDir, indexPath));
60
+ }
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "react-cosmos-plugin-vite",
3
- "version": "6.0.0-beta.5",
3
+ "version": "6.0.0-beta.7",
4
4
  "description": "Vite plugin for React Cosmos",
5
5
  "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-plugin-vite",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "cosmos.plugin.json",
9
9
  "dependencies": {
10
- "react-cosmos-core": "6.0.0-beta.5",
11
- "react-cosmos-dom": "6.0.0-beta.5"
10
+ "react-cosmos-core": "6.0.0-beta.7",
11
+ "react-cosmos-dom": "6.0.0-beta.7"
12
12
  },
13
13
  "peerDependencies": {
14
14
  "vite": "*"
15
15
  },
16
- "gitHead": "43919661a2ceb070ebc958bb7f6e52d5422ddc65"
16
+ "gitHead": "0d57027263ffb3d55fa1feb31db3640db2e89cc9"
17
17
  }