@makcbrain/storybook-framework-react-esbuild 1.0.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 +146 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/preset.d.ts +4 -0
- package/dist/preset.js +11 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.js +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Maksim Kadochnikov
|
|
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,146 @@
|
|
|
1
|
+
# @makcbrain/storybook-framework-react-esbuild
|
|
2
|
+
|
|
3
|
+
Storybook framework for React with esbuild builder.
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
This framework integrates React with Storybook using esbuild as the build system. It supports autodocs and MDX.
|
|
8
|
+
|
|
9
|
+
**Supported React versions:** 16.8 - 19
|
|
10
|
+
|
|
11
|
+
**Note:** Static build is not supported.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --save-dev @makcbrain/storybook-framework-react-esbuild
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
### Basic Setup
|
|
22
|
+
|
|
23
|
+
`.storybook/main.ts`:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import type { StorybookConfig } from '@makcbrain/storybook-framework-react-esbuild';
|
|
27
|
+
|
|
28
|
+
const config: StorybookConfig = {
|
|
29
|
+
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
30
|
+
addons: ['@storybook/addon-docs'],
|
|
31
|
+
framework: {
|
|
32
|
+
name: '@makcbrain/storybook-framework-react-esbuild',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default config;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Framework Options
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const config: StorybookConfig = {
|
|
43
|
+
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
44
|
+
framework: {
|
|
45
|
+
name: '@makcbrain/storybook-framework-react-esbuild',
|
|
46
|
+
options: {
|
|
47
|
+
// Builder options
|
|
48
|
+
builder: {
|
|
49
|
+
esbuildConfig: ({ isProduction }) => {
|
|
50
|
+
return {
|
|
51
|
+
sourcemap: !isProduction,
|
|
52
|
+
minify: isProduction,
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
// Enable React strict mode
|
|
57
|
+
strictMode: true,
|
|
58
|
+
// Use React 17 legacy root API (default: false)
|
|
59
|
+
legacyRootApi: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### esbuild Configuration
|
|
66
|
+
|
|
67
|
+
#### builder.esbuildConfig (Recommended)
|
|
68
|
+
|
|
69
|
+
Use `builder.esbuildConfig` to provide your project's esbuild configuration. The framework will automatically add required properties such as `entryPoints` with story files and necessary plugins.
|
|
70
|
+
|
|
71
|
+
**This is the recommended approach for most users.**
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const config: StorybookConfig = {
|
|
75
|
+
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
76
|
+
framework: {
|
|
77
|
+
name: '@makcbrain/storybook-framework-react-esbuild',
|
|
78
|
+
options: {
|
|
79
|
+
builder: {
|
|
80
|
+
esbuildConfig: ({ isProduction }) => {
|
|
81
|
+
// Return your project's esbuild config
|
|
82
|
+
// Framework will merge this with required Storybook settings
|
|
83
|
+
return {
|
|
84
|
+
sourcemap: !isProduction,
|
|
85
|
+
target: 'es2020',
|
|
86
|
+
jsxDev: !isProduction,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### esbuildFinal (Advanced)
|
|
96
|
+
|
|
97
|
+
Use `esbuildFinal` only when you need to patch the final esbuild configuration after the framework has applied all settings. This is rarely needed.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const config: StorybookConfig = {
|
|
101
|
+
stories: ['../stories/**/*.stories.@(js|jsx|ts|tsx)'],
|
|
102
|
+
framework: {
|
|
103
|
+
name: '@makcbrain/storybook-framework-react-esbuild',
|
|
104
|
+
},
|
|
105
|
+
esbuildFinal: (config) => {
|
|
106
|
+
// Modify the final esbuild config if needed
|
|
107
|
+
// Most users should use builder.esbuildConfig instead
|
|
108
|
+
return config;
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Type Definitions
|
|
114
|
+
|
|
115
|
+
### StorybookConfig
|
|
116
|
+
|
|
117
|
+
Main configuration type for `.storybook/main.ts`.
|
|
118
|
+
|
|
119
|
+
### FrameworkOptions
|
|
120
|
+
|
|
121
|
+
- `builder`: Builder-specific options
|
|
122
|
+
- `esbuildConfig`: Function that returns your project's esbuild configuration. The framework will merge this with required Storybook settings.
|
|
123
|
+
- `strictMode`: Enable React strict mode (boolean)
|
|
124
|
+
- `legacyRootApi`: Use React 17 legacy root API (boolean, default: false)
|
|
125
|
+
|
|
126
|
+
## Features
|
|
127
|
+
|
|
128
|
+
- **React 16.8 - 19**: Support for React versions from 16.8 to 19
|
|
129
|
+
- **Autodocs**: Automatic documentation generation from component props
|
|
130
|
+
- **MDX Support**: Write documentation in MDX format
|
|
131
|
+
- **TypeScript**: Full TypeScript support with type checking
|
|
132
|
+
- **Source Maps**: Configurable source map generation
|
|
133
|
+
|
|
134
|
+
## Limitations
|
|
135
|
+
|
|
136
|
+
- Static build is not supported
|
|
137
|
+
- No Hot Module Replacement (stories reload on file changes)
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT
|
|
142
|
+
|
|
143
|
+
## Links
|
|
144
|
+
|
|
145
|
+
- [Builder Package](https://www.npmjs.com/package/@makcbrain/storybook-builder-esbuild)
|
|
146
|
+
- [Storybook Documentation](https://storybook.js.org)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/preset.d.ts
ADDED
package/dist/preset.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { dirname, join } from 'node:path';
|
|
2
|
+
const getAbsolutePath = (value) => {
|
|
3
|
+
return dirname(require.resolve(join(value, 'package.json')));
|
|
4
|
+
};
|
|
5
|
+
export const core = {
|
|
6
|
+
builder: getAbsolutePath('@makcbrain/storybook-builder-esbuild'),
|
|
7
|
+
renderer: getAbsolutePath('@storybook/react'),
|
|
8
|
+
};
|
|
9
|
+
export const esbuildFinal = async (config) => {
|
|
10
|
+
return config;
|
|
11
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BuilderOptions, StorybookConfigEsbuild } from '@makcbrain/storybook-builder-esbuild';
|
|
2
|
+
import type { CompatibleString, StorybookConfig as StorybookConfigBase } from 'storybook/internal/types';
|
|
3
|
+
type FrameworkName = CompatibleString<'@makcbrain/storybook-framework-react-esbuild'>;
|
|
4
|
+
export type FrameworkOptions = {
|
|
5
|
+
builder?: BuilderOptions;
|
|
6
|
+
/**
|
|
7
|
+
* Enables <StrictMode> for React.
|
|
8
|
+
*/
|
|
9
|
+
strictMode?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Use React's legacy root API to mount components
|
|
12
|
+
*
|
|
13
|
+
* React has introduced a new root API with React 18.x to enable a whole set of new features (e.g.
|
|
14
|
+
* concurrent features) If this flag is true, the legacy Root API is used to mount components to
|
|
15
|
+
* make it easier to migrate step by step to React 18.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
legacyRootApi?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type StorybookConfigFramework = {
|
|
22
|
+
framework: FrameworkName | {
|
|
23
|
+
name: FrameworkName;
|
|
24
|
+
options: FrameworkOptions;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** The interface for Storybook configuration in `main.ts` files. */
|
|
28
|
+
export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigEsbuild | keyof StorybookConfigFramework> & StorybookConfigEsbuild & StorybookConfigFramework;
|
|
29
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@makcbrain/storybook-framework-react-esbuild",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Maksim Kadochnikov <makс.brain@gmail.com>",
|
|
5
|
+
"description": "Framework for Storybook with supporting React and esbuild",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"storybook",
|
|
10
|
+
"esbuild",
|
|
11
|
+
"framework",
|
|
12
|
+
"react",
|
|
13
|
+
"builder"
|
|
14
|
+
],
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/makcbrain/storybook-esbuild.git",
|
|
18
|
+
"directory": "packages/framework-react-esbuild"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/makcbrain/storybook-esbuild/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/makcbrain/storybook-esbuild#readme",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"LICENSE",
|
|
33
|
+
"package.json"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@makcbrain/storybook-builder-esbuild": "0.1.0",
|
|
37
|
+
"@storybook/react": "9.1.13"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./preset": {
|
|
45
|
+
"types": "./dist/preset.d.ts",
|
|
46
|
+
"default": "./dist/preset.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "rm -rf dist && bunx tsc",
|
|
52
|
+
"prepublishOnly": "(cd ../../ && bun run precommit) && bun run build"
|
|
53
|
+
}
|
|
54
|
+
}
|