@itcase/storybook-config 1.3.7 → 1.3.9

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,6 +1,7 @@
1
1
  import { mergeConfig } from 'vite';
2
2
  import svgr from 'vite-plugin-svgr';
3
3
  import { ADDONS_REACT_NATIVE_WEB } from '../addons/addonsReactNativeWeb.js';
4
+ import { reactNativeWebAliasPlugin } from '../vite/reactNativeWebAliasPlugin.js';
4
5
  const REACT_NATIVE_WEB_EXTENSIONS = [
5
6
  '.web.tsx',
6
7
  '.web.ts',
@@ -23,21 +24,21 @@ const MAIN_CONFIG_REACT_NATIVE_WEB = {
23
24
  plugins,
24
25
  }, {
25
26
  optimizeDeps: {
26
- esbuildOptions: {
27
- resolveExtensions: REACT_NATIVE_WEB_EXTENSIONS,
28
- },
29
27
  exclude: ['react-native'],
30
28
  include: ['react-native-web', 'react-native-svg'],
29
+ rolldownOptions: {
30
+ resolve: {
31
+ extensions: REACT_NATIVE_WEB_EXTENSIONS,
32
+ },
33
+ },
31
34
  },
32
- plugins: [svgr({ include: '**/*.svg' })],
35
+ plugins: [reactNativeWebAliasPlugin(), svgr({ include: '**/*.svg' })],
33
36
  resolve: {
34
- alias: [
35
- {
36
- find: /^react-native$/,
37
- replacement: 'react-native-web',
38
- },
39
- ],
40
- dedupe: ['react', 'react-dom', 'react-native', 'react-native-web'],
37
+ alias: {
38
+ '@react-native/assets-registry/registry': 'react-native-web/dist/modules/AssetRegistry',
39
+ 'react-native': 'react-native-web',
40
+ },
41
+ dedupe: ['react', 'react-dom', 'react-native-web'],
41
42
  extensions: REACT_NATIVE_WEB_EXTENSIONS,
42
43
  },
43
44
  });
@@ -0,0 +1,8 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Vite 8 / rolldown does not reliably apply RegExp `resolve.alias` entries.
4
+ * A string alias of `react-native` is also easy to lose when configs merge.
5
+ * Resolve the package (and its subpaths) in a pre plugin instead.
6
+ */
7
+ declare function reactNativeWebAliasPlugin(): Plugin;
8
+ export { reactNativeWebAliasPlugin };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Vite 8 / rolldown does not reliably apply RegExp `resolve.alias` entries.
3
+ * A string alias of `react-native` is also easy to lose when configs merge.
4
+ * Resolve the package (and its subpaths) in a pre plugin instead.
5
+ */
6
+ function reactNativeWebAliasPlugin() {
7
+ return {
8
+ name: 'itcase-react-native-web-alias',
9
+ async resolveId(id, importer, options) {
10
+ if (id === '@react-native/assets-registry/registry') {
11
+ return this.resolve('react-native-web/dist/modules/AssetRegistry', importer, { ...options, skipSelf: true });
12
+ }
13
+ if (id === 'react-native' || id.startsWith('react-native/')) {
14
+ return this.resolve(`react-native-web${id.slice('react-native'.length)}`, importer, { ...options, skipSelf: true });
15
+ }
16
+ return null;
17
+ },
18
+ enforce: 'pre',
19
+ };
20
+ }
21
+ export { reactNativeWebAliasPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itcase/storybook-config",
3
- "version": "1.3.7",
3
+ "version": "1.3.9",
4
4
  "author": "ITCase",
5
5
  "description": "Storybook configuration package",
6
6
  "engines": {