要解决Angular 9库上的Storybooks无法与启用Ivy的库一起运行的问题,可以尝试以下步骤:
确保Storybooks和所有库都已更新到兼容Angular 9的版本。
在库的tsconfig.lib.json文件中,确保启用了Ivy编译器。在"angularCompilerOptions"部分添加"enableIvy": true配置。
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/lib",
"declaration": true,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"enableIvy": true
}
}
module.exports = {
stories: ['../src/**/*.stories.(ts|tsx|js|jsx)'],
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs',
'@storybook/addon-viewport',
'@storybook/addon-storysource',
],
};
const { configure } = require('@storybook/angular');
configure(require.context('../src', true, /\.stories\.(ts|js|mdx)$/), module);
module.exports = {
addons: [
'@storybook/addon-actions',
'@storybook/addon-links',
'@storybook/addon-knobs',
{
name: '@storybook/addon-docs',
options: {
configureJSX: true,
},
},
'@storybook/addon-viewport',
'@storybook/addon-storysource',
],
};
require('../src/stories');
const { configure } = require('@storybook/angular');
configure(require.context('../src', true, /\.stories\.(ts|js|mdx)$/), module);
通过以上步骤,你应该能够在启用Ivy的库上成功运行Storybooks。