storybook-addon-modernjs 3.4.2 → 3.6.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/README.md +0 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -11
- package/dist/preset.js +66 -83
- package/package.json +10 -10
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
interface AddonOptions {
|
|
2
|
-
/**
|
|
3
|
-
* `path` of Modern.js config file
|
|
4
|
-
* @default "modern.config.ts"
|
|
5
|
-
*/
|
|
6
|
-
configPath?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
export declare interface AddonOptions {
|
|
2
|
+
/**
|
|
3
|
+
* `path` of Modern.js config file
|
|
4
|
+
* @default "modern.config.ts"
|
|
5
|
+
*/
|
|
6
|
+
configPath?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_bc75b71e0a36bf57 from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_bc75b71e0a36bf57 from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_bc75b71e0a36bf57.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_bc75b71e0a36bf57.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_bc75b71e0a36bf57.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
1
|
+
import "node:module";
|
package/dist/preset.js
CHANGED
|
@@ -1,89 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_bc75b71e0a36bf57.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_bc75b71e0a36bf57.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_bc75b71e0a36bf57.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
var __require = /* @__PURE__ */ ((x) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(x, {
|
|
13
|
-
get: (a, b) => (typeof require < "u" ? require : a)[b]
|
|
14
|
-
}) : x)(function(x) {
|
|
15
|
-
if (typeof require < "u") return require.apply(this, arguments);
|
|
16
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// src/preset.ts
|
|
20
|
-
import {
|
|
21
|
-
builderPluginAdapterBasic,
|
|
22
|
-
builderPluginAdapterHooks,
|
|
23
|
-
parseRspackConfig as parseToRsbuildConfig
|
|
24
|
-
} from "@modern-js/app-tools/builder";
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { builderPluginAdapterBasic, builderPluginAdapterHooks, parseRspackConfig } from "@modern-js/app-tools/builder";
|
|
25
4
|
import { mergeRsbuildConfig } from "@rsbuild/core";
|
|
26
|
-
import
|
|
5
|
+
import find_up from "find-up";
|
|
27
6
|
import { logger } from "rslog";
|
|
28
|
-
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
return (await import("@modern-js/plugin/cli")).createStorybookOptions;
|
|
34
|
-
} catch {
|
|
7
|
+
import { stripInheritedConfig } from "storybook-builder-rsbuild";
|
|
8
|
+
const MODERN_META_NAME = 'modern-js';
|
|
9
|
+
const MODERN_CONFIG_FILE = 'modern.config.ts';
|
|
10
|
+
const loadCreateStorybookOptions = async ()=>{
|
|
35
11
|
try {
|
|
36
|
-
|
|
37
|
-
} catch
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
12
|
+
return (await import("@modern-js/plugin/cli")).createStorybookOptions;
|
|
13
|
+
} catch {
|
|
14
|
+
try {
|
|
15
|
+
return (await import("@modern-js/plugin-v2/cli")).createStorybookOptions;
|
|
16
|
+
} catch {
|
|
17
|
+
throw new Error('Cannot resolve Modern.js Storybook plugin entry. Install @modern-js/app-tools@^3 with @modern-js/plugin, or @modern-js/app-tools@^2 with @modern-js/plugin-v2, then retry.');
|
|
18
|
+
}
|
|
41
19
|
}
|
|
42
|
-
}
|
|
43
|
-
}, PKG_NAME = "@rsbuild/core", getVersion = async (cwd) => {
|
|
44
|
-
let pkgPath = await findUp("package.json", { cwd }), pkg = __require(pkgPath);
|
|
45
|
-
return pkg.name === PKG_NAME ? pkg.version : pkg.dependencies[PKG_NAME] || pkg.devDependencies[PKG_NAME];
|
|
46
|
-
}, checkDependency = async () => {
|
|
47
|
-
let projectVersion = await getVersion(process.cwd()), recommandVersion = await getVersion(
|
|
48
|
-
__require.resolve("@modern-js/app-tools")
|
|
49
|
-
), installedVersion = await getVersion(__require.resolve("@rsbuild/core"));
|
|
50
|
-
if (!projectVersion) {
|
|
51
|
-
logger.error(
|
|
52
|
-
`Missing required dependency @rsbuild/core, please install @rsbuild/core@${recommandVersion}`
|
|
53
|
-
);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
recommandVersion !== installedVersion && logger.warn(
|
|
57
|
-
`@rsbuild/core version mismatch: expected ${recommandVersion}, got ${installedVersion}. Please install @rsbuild/core@${recommandVersion}`
|
|
58
|
-
);
|
|
59
|
-
}, rsbuildFinal = async (config, options) => {
|
|
60
|
-
await checkDependency();
|
|
61
|
-
let cwd = process.cwd(), createStorybookOptions = await loadCreateStorybookOptions(), { config: resolveConfig, getAppContext } = await createStorybookOptions({
|
|
62
|
-
cwd,
|
|
63
|
-
configFile: options.configPath || MODERN_CONFIG_FILE,
|
|
64
|
-
metaName: MODERN_META_NAME
|
|
65
|
-
}), nonStandardConfig = {
|
|
66
|
-
...resolveConfig,
|
|
67
|
-
plugins: [resolveConfig.builderPlugins]
|
|
68
|
-
}, { rsbuildConfig, rsbuildPlugins } = await parseToRsbuildConfig(
|
|
69
|
-
nonStandardConfig,
|
|
70
|
-
{
|
|
71
|
-
cwd
|
|
72
|
-
}
|
|
73
|
-
), adapterParams = {
|
|
74
|
-
appContext: getAppContext(),
|
|
75
|
-
normalizedConfig: resolveConfig
|
|
76
|
-
};
|
|
77
|
-
return stripInheritedConfig(
|
|
78
|
-
rsbuildConfig,
|
|
79
|
-
"the loaded Modern.js config"
|
|
80
|
-
), rsbuildConfig.plugins = [
|
|
81
|
-
...rsbuildPlugins,
|
|
82
|
-
...rsbuildConfig.plugins || [],
|
|
83
|
-
builderPluginAdapterBasic(adapterParams),
|
|
84
|
-
builderPluginAdapterHooks(adapterParams)
|
|
85
|
-
], mergeRsbuildConfig(config, rsbuildConfig);
|
|
86
20
|
};
|
|
87
|
-
|
|
88
|
-
|
|
21
|
+
const PKG_NAME = '@rsbuild/core';
|
|
22
|
+
const getVersion = async (cwd)=>{
|
|
23
|
+
const pkgPath = await find_up('package.json', {
|
|
24
|
+
cwd
|
|
25
|
+
});
|
|
26
|
+
const pkg = require(pkgPath);
|
|
27
|
+
if (pkg.name === PKG_NAME) return pkg.version;
|
|
28
|
+
return pkg.dependencies[PKG_NAME] || pkg.devDependencies[PKG_NAME];
|
|
29
|
+
};
|
|
30
|
+
const checkDependency = async ()=>{
|
|
31
|
+
const projectVersion = await getVersion(process.cwd());
|
|
32
|
+
const recommandVersion = await getVersion(require.resolve('@modern-js/app-tools'));
|
|
33
|
+
const installedVersion = await getVersion(require.resolve('@rsbuild/core'));
|
|
34
|
+
if (!projectVersion) return void logger.error(`Missing required dependency @rsbuild/core, please install @rsbuild/core@${recommandVersion}`);
|
|
35
|
+
if (recommandVersion !== installedVersion) logger.warn(`@rsbuild/core version mismatch: expected ${recommandVersion}, got ${installedVersion}. Please install @rsbuild/core@${recommandVersion}`);
|
|
36
|
+
};
|
|
37
|
+
const rsbuildFinal = async (config, options)=>{
|
|
38
|
+
await checkDependency();
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
const createStorybookOptions = await loadCreateStorybookOptions();
|
|
41
|
+
const { config: resolveConfig, getAppContext } = await createStorybookOptions({
|
|
42
|
+
cwd,
|
|
43
|
+
configFile: options.configPath || MODERN_CONFIG_FILE,
|
|
44
|
+
metaName: MODERN_META_NAME
|
|
45
|
+
});
|
|
46
|
+
const nonStandardConfig = {
|
|
47
|
+
...resolveConfig,
|
|
48
|
+
plugins: [
|
|
49
|
+
resolveConfig.builderPlugins
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
const { rsbuildConfig, rsbuildPlugins } = await parseRspackConfig(nonStandardConfig, {
|
|
53
|
+
cwd
|
|
54
|
+
});
|
|
55
|
+
const appContext = getAppContext();
|
|
56
|
+
const adapterParams = {
|
|
57
|
+
appContext: appContext,
|
|
58
|
+
normalizedConfig: resolveConfig
|
|
59
|
+
};
|
|
60
|
+
const { environments, ...topLevel } = rsbuildConfig;
|
|
61
|
+
const browserEnvironment = environments?.client ?? environments?.web;
|
|
62
|
+
const inherited = browserEnvironment ? mergeRsbuildConfig(topLevel, browserEnvironment) : topLevel;
|
|
63
|
+
stripInheritedConfig(inherited, 'the loaded Modern.js config');
|
|
64
|
+
inherited.plugins = [
|
|
65
|
+
...rsbuildPlugins,
|
|
66
|
+
...inherited.plugins || [],
|
|
67
|
+
builderPluginAdapterBasic(adapterParams),
|
|
68
|
+
builderPluginAdapterHooks(adapterParams)
|
|
69
|
+
];
|
|
70
|
+
return mergeRsbuildConfig(config, inherited);
|
|
89
71
|
};
|
|
72
|
+
export { rsbuildFinal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-addon-modernjs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Storybook addon for loading configuration of Modern.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -40,20 +40,21 @@
|
|
|
40
40
|
"rslog": "1.3.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@modern-js/
|
|
45
|
-
"@
|
|
43
|
+
"@microsoft/api-extractor": "^7.59.1",
|
|
44
|
+
"@modern-js/app-tools": "^3.9.2",
|
|
45
|
+
"@modern-js/plugin": "^3.9.2",
|
|
46
|
+
"@rsbuild/core": "^2.2.6",
|
|
46
47
|
"@types/node": "^22.0.0",
|
|
47
|
-
"storybook": "10.
|
|
48
|
+
"storybook": "10.6.0",
|
|
48
49
|
"typescript": "^5.9.3",
|
|
49
|
-
"storybook-builder-rsbuild": "3.
|
|
50
|
+
"storybook-builder-rsbuild": "3.6.0"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
53
|
"@modern-js/app-tools": "^2.67.9 || ^3.0.0-0",
|
|
53
54
|
"@modern-js/plugin": "^3.0.0",
|
|
54
55
|
"@modern-js/plugin-v2": "^2.70.4",
|
|
55
56
|
"@rsbuild/core": "^1.5.0 || ^2.0.0-0",
|
|
56
|
-
"storybook-builder-rsbuild": "^3.
|
|
57
|
+
"storybook-builder-rsbuild": "^3.6.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependenciesMeta": {
|
|
59
60
|
"@modern-js/plugin": {
|
|
@@ -77,8 +78,7 @@
|
|
|
77
78
|
"platform": "node"
|
|
78
79
|
},
|
|
79
80
|
"scripts": {
|
|
80
|
-
"build": "
|
|
81
|
-
"
|
|
82
|
-
"prep": "jiti ../../scripts/build/build-package.ts"
|
|
81
|
+
"build": "rstack lib",
|
|
82
|
+
"dev": "rstack lib --watch"
|
|
83
83
|
}
|
|
84
84
|
}
|