storybook-react-native-web-rsbuild 3.2.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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +6 -0
- package/dist/node/index.d.ts +43 -0
- package/dist/node/index.js +19 -0
- package/dist/preset.js +60 -0
- package/package.json +86 -0
- package/preset.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Rspack Contrib
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# storybook-react-native-web-rsbuild
|
|
2
|
+
|
|
3
|
+
Storybook for React Native Web and Rsbuild: Develop React Native components for web in isolation with Hot Reloading.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install storybook-react-native-web-rsbuild react-native-web
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
In your `.storybook/main.ts`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import type { StorybookConfig } from 'storybook-react-native-web-rsbuild'
|
|
17
|
+
|
|
18
|
+
const config: StorybookConfig = {
|
|
19
|
+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
20
|
+
addons: ['@storybook/addon-docs'],
|
|
21
|
+
framework: {
|
|
22
|
+
name: 'storybook-react-native-web-rsbuild',
|
|
23
|
+
options: {},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default config
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Framework Options
|
|
31
|
+
|
|
32
|
+
### modulesToTranspile
|
|
33
|
+
|
|
34
|
+
Many React Native packages ship untranspiled code. Use this option to add additional packages that need transpilation:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
framework: {
|
|
38
|
+
name: 'storybook-react-native-web-rsbuild',
|
|
39
|
+
options: {
|
|
40
|
+
modulesToTranspile: ['react-native-reanimated', 'nativewind'],
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
By default, packages starting with `react-native`, `@react-native`, `expo`, and `@expo` are already included.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Full React Native Web support with Rsbuild
|
|
50
|
+
- Aliases `react-native` to `react-native-web` automatically
|
|
51
|
+
- Handles untranspiled React Native packages
|
|
52
|
+
- Supports Flow syntax in React Native packages
|
|
53
|
+
- Compatible with Expo projects
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export * from '@storybook/react';
|
|
2
|
+
export { __definePreview as definePreview } from '@storybook/react';
|
|
3
|
+
import { PluginReactNativeWebOptions } from 'rsbuild-plugin-react-native-web';
|
|
4
|
+
import { StorybookConfig as StorybookConfig$1, TypescriptOptions } from 'storybook/internal/types';
|
|
5
|
+
import { BuilderOptions, StorybookConfigRsbuild, TypescriptOptions as TypescriptOptions$1 } from 'storybook-builder-rsbuild';
|
|
6
|
+
|
|
7
|
+
type FrameworkName = 'storybook-react-native-web-rsbuild';
|
|
8
|
+
type BuilderName = 'storybook-builder-rsbuild';
|
|
9
|
+
type FrameworkOptions = {
|
|
10
|
+
builder?: BuilderOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Additional node_modules that need to be transpiled.
|
|
13
|
+
* Many React Native packages ship untranspiled code.
|
|
14
|
+
* By default, packages starting with `react-native`, `@react-native`, `expo`, and `@expo`
|
|
15
|
+
* are already included.
|
|
16
|
+
*
|
|
17
|
+
* @example ['react-native-reanimated', 'nativewind']
|
|
18
|
+
*/
|
|
19
|
+
modulesToTranspile?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Options passed to the React Native Web Rsbuild plugin.
|
|
22
|
+
*/
|
|
23
|
+
pluginOptions?: PluginReactNativeWebOptions;
|
|
24
|
+
};
|
|
25
|
+
type StorybookConfigFramework = {
|
|
26
|
+
framework: FrameworkName | {
|
|
27
|
+
name: FrameworkName;
|
|
28
|
+
options: FrameworkOptions;
|
|
29
|
+
};
|
|
30
|
+
core?: StorybookConfig$1['core'] & {
|
|
31
|
+
builder?: BuilderName | {
|
|
32
|
+
name: BuilderName;
|
|
33
|
+
options: BuilderOptions;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
typescript?: Partial<TypescriptOptions & TypescriptOptions$1>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The interface for Storybook configuration in `main.ts` files.
|
|
40
|
+
*/
|
|
41
|
+
type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
|
|
42
|
+
|
|
43
|
+
export type { FrameworkOptions, StorybookConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PluginReactNativeWebOptions } from 'rsbuild-plugin-react-native-web';
|
|
2
|
+
import { StorybookConfig as StorybookConfig$1, TypescriptOptions } from 'storybook/internal/types';
|
|
3
|
+
import { StorybookConfigRsbuild, BuilderOptions, TypescriptOptions as TypescriptOptions$1 } from 'storybook-builder-rsbuild';
|
|
4
|
+
|
|
5
|
+
type FrameworkName = 'storybook-react-native-web-rsbuild';
|
|
6
|
+
type BuilderName = 'storybook-builder-rsbuild';
|
|
7
|
+
type FrameworkOptions = {
|
|
8
|
+
builder?: BuilderOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Additional node_modules that need to be transpiled.
|
|
11
|
+
* Many React Native packages ship untranspiled code.
|
|
12
|
+
* By default, packages starting with `react-native`, `@react-native`, `expo`, and `@expo`
|
|
13
|
+
* are already included.
|
|
14
|
+
*
|
|
15
|
+
* @example ['react-native-reanimated', 'nativewind']
|
|
16
|
+
*/
|
|
17
|
+
modulesToTranspile?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Options passed to the React Native Web Rsbuild plugin.
|
|
20
|
+
*/
|
|
21
|
+
pluginOptions?: PluginReactNativeWebOptions;
|
|
22
|
+
};
|
|
23
|
+
type StorybookConfigFramework = {
|
|
24
|
+
framework: FrameworkName | {
|
|
25
|
+
name: FrameworkName;
|
|
26
|
+
options: FrameworkOptions;
|
|
27
|
+
};
|
|
28
|
+
core?: StorybookConfig$1['core'] & {
|
|
29
|
+
builder?: BuilderName | {
|
|
30
|
+
name: BuilderName;
|
|
31
|
+
options: BuilderOptions;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
typescript?: Partial<TypescriptOptions & TypescriptOptions$1>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The interface for Storybook configuration in `main.ts` files.
|
|
38
|
+
*/
|
|
39
|
+
type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigRsbuild | keyof StorybookConfigFramework> & StorybookConfigRsbuild & StorybookConfigFramework;
|
|
40
|
+
|
|
41
|
+
declare function defineMain(config: StorybookConfig): StorybookConfig;
|
|
42
|
+
|
|
43
|
+
export { defineMain };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_cc63eba5417a6086 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_cc63eba5417a6086 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_cc63eba5417a6086 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_cc63eba5417a6086.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_cc63eba5417a6086.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_cc63eba5417a6086.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/node/index.ts
|
|
14
|
+
function defineMain(config) {
|
|
15
|
+
return config;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
defineMain
|
|
19
|
+
};
|
package/dist/preset.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_cc63eba5417a6086 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_cc63eba5417a6086 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_cc63eba5417a6086 from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_cc63eba5417a6086.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_cc63eba5417a6086.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_cc63eba5417a6086.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/preset.ts
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import { dirname } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
18
|
+
import { pluginReactNativeWeb } from "rsbuild-plugin-react-native-web";
|
|
19
|
+
import { rsbuildFinal as reactRsbuildFinal } from "storybook-react-rsbuild/preset";
|
|
20
|
+
function resolveReactNativeWeb(configDir) {
|
|
21
|
+
try {
|
|
22
|
+
let packageJsonPath = createRequire(`${configDir}/package.json`).resolve("react-native-web/package.json");
|
|
23
|
+
return dirname(packageJsonPath);
|
|
24
|
+
} catch {
|
|
25
|
+
return "react-native-web";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
var rsbuildFinal = async (config, options) => {
|
|
29
|
+
let reactConfig = await reactRsbuildFinal(config, options), framework = await options.presets.apply("framework"), frameworkOptions = typeof framework == "string" ? {} : framework.options || {}, reactNativeWebPath = resolveReactNativeWeb(options.configDir);
|
|
30
|
+
return mergeRsbuildConfig(reactConfig, {
|
|
31
|
+
plugins: [
|
|
32
|
+
pluginReactNativeWeb({
|
|
33
|
+
modulesToTranspile: frameworkOptions.modulesToTranspile,
|
|
34
|
+
// Pass the resolved path to enable absolute imports in transformed code
|
|
35
|
+
reactNativeWebPath,
|
|
36
|
+
...frameworkOptions.pluginOptions
|
|
37
|
+
})
|
|
38
|
+
],
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: {
|
|
41
|
+
// Use absolute path to ensure proper resolution in pnpm/monorepo setups
|
|
42
|
+
"react-native": reactNativeWebPath
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}, core = async (config, options) => {
|
|
47
|
+
let framework = await options.presets.apply("framework");
|
|
48
|
+
return {
|
|
49
|
+
...config,
|
|
50
|
+
builder: {
|
|
51
|
+
name: fileURLToPath(import.meta.resolve("storybook-builder-rsbuild")),
|
|
52
|
+
options: typeof framework == "string" ? {} : framework.options.builder || {}
|
|
53
|
+
},
|
|
54
|
+
renderer: fileURLToPath(import.meta.resolve("@storybook/react/preset"))
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export {
|
|
58
|
+
core,
|
|
59
|
+
rsbuildFinal
|
|
60
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "storybook-react-native-web-rsbuild",
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"description": "Storybook for React Native Web and Rsbuild: Develop React Native components for web in isolation with Hot Reloading.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"storybook",
|
|
7
|
+
"rsbuild",
|
|
8
|
+
"rspack",
|
|
9
|
+
"react-native",
|
|
10
|
+
"react-native-web",
|
|
11
|
+
"expo"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://storybook.rsbuild.rs",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/rspack-contrib/storybook-rsbuild/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/rspack-contrib/storybook-rsbuild",
|
|
20
|
+
"directory": "packages/framework-react-native-web"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./node": {
|
|
30
|
+
"types": "./dist/node/index.d.ts",
|
|
31
|
+
"default": "./dist/node/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./preset": "./dist/preset.js"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/**/*",
|
|
38
|
+
"README.md",
|
|
39
|
+
"*.js",
|
|
40
|
+
"*.d.ts",
|
|
41
|
+
"!src/**/*"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "pnpm run prep --production",
|
|
45
|
+
"check": "jiti ../../scripts/check/check-package.ts",
|
|
46
|
+
"prep": "jiti ../../scripts/build/build-package.ts",
|
|
47
|
+
"prepare": "pnpm run build"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@storybook/react": "^10.1.9",
|
|
51
|
+
"rsbuild-plugin-react-native-web": "workspace:*",
|
|
52
|
+
"storybook-builder-rsbuild": "workspace:*",
|
|
53
|
+
"storybook-react-rsbuild": "workspace:*"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@rsbuild/core": "^1.6.13",
|
|
57
|
+
"@types/node": "^22.0.0",
|
|
58
|
+
"@types/react": "^18.3.27",
|
|
59
|
+
"react": "18.3.1",
|
|
60
|
+
"react-dom": "18.3.1",
|
|
61
|
+
"react-native-web": "^0.19.13",
|
|
62
|
+
"storybook": "10.1.2",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@rsbuild/core": "^1.5.0",
|
|
67
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
68
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
69
|
+
"react-native-web": "^0.19.0 || ^0.20.0 || ^0.21.0",
|
|
70
|
+
"storybook": "^10.1.0"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=18.0.0"
|
|
74
|
+
},
|
|
75
|
+
"publishConfig": {
|
|
76
|
+
"access": "public"
|
|
77
|
+
},
|
|
78
|
+
"bundler": {
|
|
79
|
+
"entries": [
|
|
80
|
+
"./src/node/index.ts",
|
|
81
|
+
"./src/index.ts",
|
|
82
|
+
"./src/preset.ts"
|
|
83
|
+
],
|
|
84
|
+
"platform": "node"
|
|
85
|
+
}
|
|
86
|
+
}
|
package/preset.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/preset.js'
|