@storybook/angular 7.0.0-alpha.7 → 7.0.0-beta.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/.eslintrc.js +8 -0
- package/README.md +1 -1
- package/dist/{types/builders → builders}/build-storybook/index.d.ts +3 -3
- package/dist/{types/builders → builders}/build-storybook/index.js +0 -0
- package/dist/builders/build-storybook/index.spec.d.ts +1 -0
- package/dist/builders/build-storybook/index.spec.js +218 -0
- package/dist/{types/builders → builders}/build-storybook/schema.json +0 -0
- package/dist/{types/builders → builders}/builders.json +0 -0
- package/dist/{types/builders → builders}/start-storybook/index.d.ts +3 -3
- package/dist/{types/builders → builders}/start-storybook/index.js +0 -0
- package/dist/builders/start-storybook/index.spec.d.ts +1 -0
- package/dist/builders/start-storybook/index.spec.js +214 -0
- package/dist/{types/builders → builders}/start-storybook/schema.json +0 -0
- package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/build-standalone-errors-handler.js +3 -6
- package/dist/{types/builders → builders}/utils/run-compodoc.d.ts +0 -0
- package/dist/{types/builders → builders}/utils/run-compodoc.js +0 -1
- package/dist/builders/utils/run-compodoc.spec.d.ts +1 -0
- package/dist/builders/utils/run-compodoc.spec.js +59 -0
- package/dist/{types/builders → builders}/utils/standalone-options.d.ts +3 -3
- package/dist/{types/builders → builders}/utils/standalone-options.js +0 -0
- package/dist/{types/client → client}/angular/app.component.d.ts +1 -1
- package/dist/{types/client → client}/angular/app.component.js +0 -1
- package/dist/{types/client → client}/angular/app.token.d.ts +0 -0
- package/dist/{types/client → client}/angular/app.token.js +0 -0
- package/dist/{types/client → client}/angular/helpers.d.ts +3 -3
- package/dist/{types/client → client}/angular/helpers.js +1 -2
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/AbstractRenderer.js +13 -13
- package/dist/{types/client → client}/angular-beta/CanvasRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/CanvasRenderer.js +0 -0
- package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.d.ts +3 -3
- package/dist/{types/client → client}/angular-beta/ComputesTemplateFromComponent.js +3 -3
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +390 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/DocsRenderer.js +5 -8
- package/dist/{types/client → client}/angular-beta/RendererFactory.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/RendererFactory.js +3 -3
- package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
- package/dist/client/angular-beta/RendererFactory.test.js +297 -0
- package/dist/{types/client → client}/angular-beta/StorybookModule.d.ts +2 -2
- package/dist/{types/client → client}/angular-beta/StorybookModule.js +4 -23
- package/dist/client/angular-beta/StorybookModule.test.d.ts +1 -0
- package/dist/client/angular-beta/StorybookModule.test.js +279 -0
- package/dist/{types/client → client}/angular-beta/StorybookProvider.d.ts +1 -1
- package/dist/{types/client → client}/angular-beta/StorybookProvider.js +0 -0
- package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/StorybookWrapperComponent.js +0 -1
- package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +26 -0
- package/dist/client/angular-beta/__testfixtures__/input.component.js +67 -0
- package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.d.ts +2 -2
- package/dist/{types/client → client}/angular-beta/utils/NgComponentAnalyzer.js +0 -0
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +1 -0
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +340 -0
- package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -0
- package/dist/{types/client → client}/angular-beta/utils/NgModulesAnalyzer.js +0 -0
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +1 -0
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +23 -0
- package/dist/client/config.d.ts +6 -0
- package/dist/client/config.js +10 -0
- package/dist/client/decorateStory.d.ts +4 -0
- package/dist/{types/client → client}/decorateStory.js +3 -3
- package/dist/client/decorateStory.test.d.ts +1 -0
- package/dist/client/decorateStory.test.js +335 -0
- package/dist/client/decorators.d.ts +5 -0
- package/dist/{types/client → client}/decorators.js +0 -0
- package/dist/client/decorators.test.d.ts +1 -0
- package/dist/client/decorators.test.js +106 -0
- package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +111 -0
- package/dist/client/docs/__testfixtures__/doc-button/input.js +207 -0
- package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +7 -0
- package/dist/client/docs/angular-properties.test.d.ts +1 -0
- package/dist/client/docs/angular-properties.test.js +56 -0
- package/dist/{types/client → client}/docs/compodoc.d.ts +5 -11
- package/dist/{types/client → client}/docs/compodoc.js +7 -7
- package/dist/client/docs/compodoc.test.d.ts +1 -0
- package/dist/client/docs/compodoc.test.js +131 -0
- package/dist/client/docs/config.d.ts +4 -0
- package/dist/{types/client → client}/docs/config.js +0 -0
- package/dist/{types/client → client}/docs/index.d.ts +0 -0
- package/dist/{types/client → client}/docs/index.js +0 -0
- package/dist/{types/client → client}/docs/sourceDecorator.d.ts +3 -3
- package/dist/{types/client → client}/docs/sourceDecorator.js +3 -3
- package/dist/{types/client → client}/docs/types.d.ts +1 -1
- package/dist/{types/client → client}/docs/types.js +0 -0
- package/dist/{types/client → client}/globals.d.ts +0 -0
- package/dist/{types/client → client}/globals.js +0 -0
- package/dist/{types/client → client}/index.d.ts +0 -0
- package/dist/{types/client → client}/index.js +3 -0
- package/dist/client/public-api.d.ts +15 -0
- package/dist/{types/client → client}/public-api.js +2 -9
- package/dist/client/public-types.d.ts +36 -0
- package/dist/{types/client → client}/public-types.js +0 -0
- package/dist/client/render.d.ts +6 -0
- package/dist/{types/client → client}/render.js +3 -3
- package/dist/{types/client → client}/types.d.ts +9 -13
- package/dist/{types/client → client}/types.js +0 -0
- package/dist/{types/index.d.ts → index.d.ts} +0 -0
- package/dist/{types/index.js → index.js} +0 -0
- package/dist/{types/preset.d.ts → preset.d.ts} +1 -1
- package/dist/{types/preset.js → preset.js} +0 -1
- package/dist/{types/renderer.d.ts → renderer.d.ts} +0 -0
- package/dist/{types/renderer.js → renderer.js} +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -0
- package/dist/{types/server/__mocks-ng-workspace__/some-config → server/__mocks-ng-workspace__/minimal-config}/tsconfig.json +1 -4
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -0
- package/dist/{types/server/__mocks-ng-workspace__/with-angularBrowserTarget → server/__mocks-ng-workspace__/some-config}/tsconfig.json +1 -4
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -0
- package/dist/{types/server/__mocks-ng-workspace__/minimal-config → server/__mocks-ng-workspace__/with-angularBrowserTarget}/tsconfig.json +1 -4
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -0
- package/dist/{types/server/__mocks-ng-workspace__/without-projects-entry → server/__mocks-ng-workspace__/with-lib}/projects/pattern-lib/tsconfig.lib.json +2 -8
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-lib/tsconfig.json +1 -4
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/nx.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -0
- package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +14 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -0
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +14 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -0
- package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +13 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -0
- package/dist/{types/server/__mocks-ng-workspace__/with-lib → server/__mocks-ng-workspace__/without-projects-entry}/projects/pattern-lib/tsconfig.lib.json +2 -8
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +13 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -0
- package/dist/{types/server → server}/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -0
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +13 -0
- package/dist/server/__tests__/angular.json +96 -0
- package/dist/{types/server/angular-cli-webpack-12.2.x.d.ts → server/angular-cli-webpack.d.ts} +0 -0
- package/dist/{types/server/angular-cli-webpack-13.x.x.js → server/angular-cli-webpack.js} +6 -1
- package/dist/{types/server → server}/angular-read-workspace.d.ts +0 -0
- package/dist/{types/server → server}/angular-read-workspace.js +1 -1
- package/dist/{types/server → server}/framework-preset-angular-cli.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-cli.js +5 -24
- package/dist/server/framework-preset-angular-cli.test.d.ts +1 -0
- package/dist/server/framework-preset-angular-cli.test.js +698 -0
- package/dist/{types/server → server}/framework-preset-angular-docs.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-docs.js +1 -1
- package/dist/{types/server → server}/framework-preset-angular-ivy.d.ts +1 -1
- package/dist/{types/server → server}/framework-preset-angular-ivy.js +4 -2
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +25 -0
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +46 -0
- package/dist/{types/server → server}/preset-options.d.ts +2 -2
- package/dist/{types/server → server}/preset-options.js +0 -0
- package/dist/{types/server → server}/utils/filter-out-styling-rules.d.ts +1 -1
- package/dist/{types/server → server}/utils/filter-out-styling-rules.js +0 -0
- package/dist/{types/server → server}/utils/module-is-available.d.ts +0 -0
- package/dist/{types/server → server}/utils/module-is-available.js +0 -0
- package/dist/{types/server → server}/utils/normalize-asset-patterns.d.ts +1 -1
- package/dist/{types/server → server}/utils/normalize-asset-patterns.js +0 -0
- package/dist/{types/server → server}/utils/normalize-optimization.d.ts +0 -0
- package/dist/{types/server → server}/utils/normalize-optimization.js +0 -0
- package/dist/types.d.ts +29 -0
- package/dist/{types/types.js → types.js} +0 -0
- package/jest.config.js +8 -1
- package/package.json +49 -54
- package/preset.js +1 -1
- package/renderer.d.ts +1 -1
- package/renderer.js +1 -1
- package/template/cli/.eslintrc.json +5 -0
- package/template/cli/Button.stories.ts +51 -0
- package/template/cli/Header.stories.ts +37 -0
- package/template/cli/Page.stories.ts +46 -0
- package/template/cli/User.ts +2 -0
- package/template/cli/button.component.ts +53 -0
- package/template/cli/header.component.ts +75 -0
- package/template/cli/page.component.ts +77 -0
- package/template/components/button.component.ts +54 -0
- package/template/components/button.css +30 -0
- package/template/components/form.component.ts +37 -0
- package/template/components/html.component.ts +22 -0
- package/template/components/index.js +8 -0
- package/template/components/pre.component.ts +29 -0
- package/template/stories/angular-mdx.stories.mdx +25 -0
- package/template/stories/argTypes/doc-button/doc-button.component.html +7 -0
- package/template/stories/argTypes/doc-button/doc-button.component.scss +3 -0
- package/template/stories/argTypes/doc-button/doc-button.component.ts +233 -0
- package/template/stories/argTypes/doc-button/doc-button.stories.ts +24 -0
- package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +24 -0
- package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +14 -0
- package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +27 -0
- package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +17 -0
- package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +18 -0
- package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +17 -0
- package/template/stories/basics/README.stories.mdx +7 -0
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +27 -0
- package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +57 -0
- package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +19 -0
- package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +19 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +8 -0
- package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +37 -0
- package/template/stories/basics/component-with-enums/enums.component.html +8 -0
- package/template/stories/basics/component-with-enums/enums.component.stories.ts +24 -0
- package/template/stories/basics/component-with-enums/enums.component.ts +53 -0
- package/template/stories/basics/component-with-inheritance/base-button.component.ts +10 -0
- package/template/stories/basics/component-with-inheritance/base-button.stories.ts +12 -0
- package/template/stories/basics/component-with-inheritance/icon-button.component.ts +11 -0
- package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +13 -0
- package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +58 -0
- package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +29 -0
- package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +42 -0
- package/template/stories/basics/component-with-on-push/on-push-box.component.ts +21 -0
- package/template/stories/basics/component-with-on-push/on-push.stories.ts +21 -0
- package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +31 -0
- package/template/stories/basics/component-with-pipe/custom.pipe.ts +10 -0
- package/template/stories/basics/component-with-pipe/with-pipe.component.ts +10 -0
- package/template/stories/basics/component-with-provider/di.component.html +7 -0
- package/template/stories/basics/component-with-provider/di.component.stories.ts +26 -0
- package/template/stories/basics/component-with-provider/di.component.ts +28 -0
- package/template/stories/basics/component-with-style/styled.component.css +3 -0
- package/template/stories/basics/component-with-style/styled.component.html +5 -0
- package/template/stories/basics/component-with-style/styled.component.scss +5 -0
- package/template/stories/basics/component-with-style/styled.component.stories.ts +10 -0
- package/template/stories/basics/component-with-style/styled.component.ts +8 -0
- package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +73 -0
- package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +71 -0
- package/template/stories/basics/component-without-selector/without-selector.component.ts +30 -0
- package/template/stories/basics/component-without-selector/without-selector.stories.ts +30 -0
- package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +3 -0
- package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +29 -0
- package/template/stories/basics/ng-module/angular-src/chip.component.ts +60 -0
- package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +49 -0
- package/template/stories/basics/ng-module/angular-src/chips.module.ts +31 -0
- package/template/stories/basics/ng-module/import-module-for-root.stories.ts +50 -0
- package/template/stories/basics/ng-module/import-module.stories.ts +46 -0
- package/template/stories/button.component.ts +26 -0
- package/template/stories/core/README.stories.mdx +7 -0
- package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +20 -0
- package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +117 -0
- package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +18 -0
- package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +20 -0
- package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +10 -0
- package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +14 -0
- package/template/stories/core/moduleMetadata/angular-src/service.component.ts +24 -0
- package/template/stories/core/moduleMetadata/angular-src/token.component.ts +31 -0
- package/template/stories/core/moduleMetadata/in-export-default.stories.ts +38 -0
- package/template/stories/core/moduleMetadata/in-stories.stories.ts +46 -0
- package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +35 -0
- package/template/stories/core/parameters/bootstrap-options.stories.ts +22 -0
- package/template/stories/core/styles/story-styles.stories.ts +50 -0
- package/template/stories/others/issues/12009-unknown-component.stories.ts +14 -0
- package/template/stories/others/ngx-translate/README.stories.mdx +58 -0
- package/LICENSE +0 -21
- package/dist/types/client/config.d.ts +0 -6
- package/dist/types/client/config.js +0 -10
- package/dist/types/client/decorateStory.d.ts +0 -4
- package/dist/types/client/decorators.d.ts +0 -5
- package/dist/types/client/docs/config.d.ts +0 -14
- package/dist/types/client/public-api.d.ts +0 -23
- package/dist/types/client/public-types.d.ts +0 -27
- package/dist/types/client/render.d.ts +0 -7
- package/dist/types/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -19
- package/dist/types/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -19
- package/dist/types/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -16
- package/dist/types/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -16
- package/dist/types/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -16
- package/dist/types/server/angular-cli-webpack-12.2.x.js +0 -66
- package/dist/types/server/angular-cli-webpack-13.x.x.d.ts +0 -1
- package/dist/types/server/angular-cli-webpack-older.d.ts +0 -6
- package/dist/types/server/angular-cli-webpack-older.js +0 -111
- package/dist/types/server/angular-devkit-build-webpack.d.ts +0 -30
- package/dist/types/server/angular-devkit-build-webpack.js +0 -164
- package/dist/types/server/create-fork-ts-checker-plugin.d.ts +0 -3
- package/dist/types/server/create-fork-ts-checker-plugin.js +0 -19
- package/dist/types/server/framework-preset-angular.d.ts +0 -5
- package/dist/types/server/framework-preset-angular.js +0 -103
- package/dist/types/server/ngx-template-loader/index.d.ts +0 -1
- package/dist/types/server/ngx-template-loader/index.js +0 -46
- package/dist/types/server/ts_config.d.ts +0 -2
- package/dist/types/server/ts_config.js +0 -28
- package/dist/types/types.d.ts +0 -28
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const node_logger_1 = require("@storybook/node-logger");
|
|
8
|
+
const core_1 = require("@angular-devkit/core");
|
|
9
|
+
const framework_preset_angular_cli_1 = require("./framework-preset-angular-cli");
|
|
10
|
+
const testPath = __dirname;
|
|
11
|
+
let workspaceRoot = testPath;
|
|
12
|
+
let cwdSpy;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
cwdSpy = jest.spyOn(process, 'cwd');
|
|
15
|
+
jest.spyOn(node_logger_1.logger, 'error').mockImplementation();
|
|
16
|
+
jest.spyOn(node_logger_1.logger, 'info').mockImplementation();
|
|
17
|
+
});
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
jest.clearAllMocks();
|
|
20
|
+
});
|
|
21
|
+
function initMockWorkspace(name) {
|
|
22
|
+
workspaceRoot = path_1.default.join(__dirname, '__mocks-ng-workspace__', name);
|
|
23
|
+
cwdSpy.mockReturnValue(workspaceRoot);
|
|
24
|
+
}
|
|
25
|
+
describe('framework-preset-angular-cli', () => {
|
|
26
|
+
let options;
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
options = {};
|
|
29
|
+
});
|
|
30
|
+
describe('without angular.json', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
initMockWorkspace('');
|
|
33
|
+
});
|
|
34
|
+
it('should return webpack base config and display log error', async () => {
|
|
35
|
+
const webpackBaseConfig = newWebpackConfiguration();
|
|
36
|
+
const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
|
|
37
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
|
|
38
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not find angular workspace config (angular.json) on this path "${workspaceRoot}"`);
|
|
39
|
+
expect(config).toEqual(webpackBaseConfig);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe("when angular.json haven't projects entry", () => {
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
initMockWorkspace('without-projects-entry');
|
|
45
|
+
});
|
|
46
|
+
it('should return webpack base config and display log error', async () => {
|
|
47
|
+
const webpackBaseConfig = newWebpackConfiguration();
|
|
48
|
+
const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
|
|
49
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
|
|
50
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: No angular projects found');
|
|
51
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
|
|
52
|
+
expect(config).toEqual(webpackBaseConfig);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('when angular.json have empty projects entry', () => {
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
initMockWorkspace('empty-projects-entry');
|
|
58
|
+
});
|
|
59
|
+
it('should return webpack base config and display log error', async () => {
|
|
60
|
+
const webpackBaseConfig = newWebpackConfiguration();
|
|
61
|
+
const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
|
|
62
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
|
|
63
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: No angular projects found');
|
|
64
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
|
|
65
|
+
expect(config).toEqual(webpackBaseConfig);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
describe('when angular.json does not have a compatible project', () => {
|
|
69
|
+
beforeEach(() => {
|
|
70
|
+
initMockWorkspace('without-compatible-projects');
|
|
71
|
+
});
|
|
72
|
+
it('should return webpack base config and display log error', async () => {
|
|
73
|
+
const webpackBaseConfig = newWebpackConfiguration();
|
|
74
|
+
const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
|
|
75
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
|
|
76
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: "missing-project" project is not found in angular.json');
|
|
77
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
|
|
78
|
+
expect(config).toEqual(webpackBaseConfig);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('when angular.json have projects without architect.build', () => {
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
initMockWorkspace('without-architect-build');
|
|
84
|
+
});
|
|
85
|
+
it('should return webpack base config and display log error', async () => {
|
|
86
|
+
const webpackBaseConfig = newWebpackConfiguration();
|
|
87
|
+
const config = await (0, framework_preset_angular_cli_1.webpackFinal)(webpackBaseConfig, options);
|
|
88
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Loading angular-cli config for angular lower than 12.2.0');
|
|
89
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith('=> Could not find angular project: "build" target is not found in "foo-project" project');
|
|
90
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledWith('=> Fail to load angular-cli config. Using base config');
|
|
91
|
+
expect(config).toEqual(webpackBaseConfig);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('when angular.json have projects without architect.build.options', () => {
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
initMockWorkspace('without-architect-build-options');
|
|
97
|
+
});
|
|
98
|
+
it('throws error', async () => {
|
|
99
|
+
await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required options in project target. Check "tsConfig"');
|
|
100
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe('when angular.json have minimal config', () => {
|
|
104
|
+
beforeEach(() => {
|
|
105
|
+
initMockWorkspace('minimal-config');
|
|
106
|
+
});
|
|
107
|
+
it('should log', async () => {
|
|
108
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
109
|
+
await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
110
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
|
|
111
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
|
|
112
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "foo-project:build" for configuring Storybook');
|
|
113
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
|
|
114
|
+
});
|
|
115
|
+
it('should extends webpack base config', async () => {
|
|
116
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
117
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
118
|
+
expect(webpackFinalConfig).toEqual({
|
|
119
|
+
...baseWebpackConfig,
|
|
120
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
121
|
+
plugins: expect.anything(),
|
|
122
|
+
resolve: {
|
|
123
|
+
...baseWebpackConfig.resolve,
|
|
124
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
125
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
126
|
+
plugins: expect.arrayContaining([
|
|
127
|
+
expect.objectContaining({
|
|
128
|
+
absoluteBaseUrl: expect.any(String),
|
|
129
|
+
}),
|
|
130
|
+
]),
|
|
131
|
+
},
|
|
132
|
+
resolveLoader: expect.anything(),
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
it('should set webpack "module.rules"', async () => {
|
|
136
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
137
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
138
|
+
const expectedRules = [
|
|
139
|
+
{
|
|
140
|
+
oneOf: [
|
|
141
|
+
{
|
|
142
|
+
exclude: [],
|
|
143
|
+
use: expect.anything(),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
include: [],
|
|
147
|
+
use: expect.anything(),
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
{ use: expect.anything() },
|
|
152
|
+
];
|
|
153
|
+
expect(webpackFinalConfig.module.rules).toEqual([
|
|
154
|
+
{
|
|
155
|
+
test: /\.(?:css)$/i,
|
|
156
|
+
rules: expectedRules,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
test: /\.(?:scss)$/i,
|
|
160
|
+
rules: expectedRules,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
test: /\.(?:sass)$/i,
|
|
164
|
+
rules: expectedRules,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
test: /\.(?:less)$/i,
|
|
168
|
+
rules: expectedRules,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
test: /\.(?:styl)$/i,
|
|
172
|
+
rules: expectedRules,
|
|
173
|
+
},
|
|
174
|
+
{ mimetype: 'text/css', use: expect.anything() },
|
|
175
|
+
{ mimetype: 'text/x-scss', use: expect.anything() },
|
|
176
|
+
{ mimetype: 'text/x-sass', use: expect.anything() },
|
|
177
|
+
{ mimetype: 'text/x-less', use: expect.anything() },
|
|
178
|
+
{ mimetype: 'text/x-stylus', use: expect.anything() },
|
|
179
|
+
...baseWebpackConfig.module.rules,
|
|
180
|
+
]);
|
|
181
|
+
});
|
|
182
|
+
it('should set webpack "plugins"', async () => {
|
|
183
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
184
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
185
|
+
expect(webpackFinalConfig.plugins).toMatchInlineSnapshot(`
|
|
186
|
+
Array [
|
|
187
|
+
AnyComponentStyleBudgetChecker {
|
|
188
|
+
"budgets": Array [],
|
|
189
|
+
},
|
|
190
|
+
Object {
|
|
191
|
+
"apply": [Function],
|
|
192
|
+
},
|
|
193
|
+
ContextReplacementPlugin {
|
|
194
|
+
"newContentCreateContextMap": [Function],
|
|
195
|
+
"newContentResource": "/Users/shilman/projects/baseline/storybook/app/angular/src/server/__mocks-ng-workspace__/minimal-config/$_lazy_route_resources",
|
|
196
|
+
"resourceRegExp": /\\\\@angular\\(\\\\\\\\\\|\\\\/\\)core\\(\\\\\\\\\\|\\\\/\\)/,
|
|
197
|
+
},
|
|
198
|
+
DedupeModuleResolvePlugin {
|
|
199
|
+
"modules": Map {},
|
|
200
|
+
"options": Object {
|
|
201
|
+
"verbose": undefined,
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
Object {
|
|
205
|
+
"keepBasePlugin": true,
|
|
206
|
+
},
|
|
207
|
+
]
|
|
208
|
+
`);
|
|
209
|
+
});
|
|
210
|
+
it('should set webpack "resolve.modules"', async () => {
|
|
211
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
212
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
213
|
+
expect(webpackFinalConfig.resolve.modules).toEqual([
|
|
214
|
+
...baseWebpackConfig.resolve.modules,
|
|
215
|
+
(0, core_1.getSystemPath)((0, core_1.normalize)(path_1.default.join(workspaceRoot, 'src'))).replace(/\\/g, '/'),
|
|
216
|
+
]);
|
|
217
|
+
});
|
|
218
|
+
it('should replace webpack "resolve.plugins"', async () => {
|
|
219
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
220
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
221
|
+
expect(webpackFinalConfig.resolve.plugins).toMatchInlineSnapshot(`
|
|
222
|
+
Array [
|
|
223
|
+
TsconfigPathsPlugin {
|
|
224
|
+
"absoluteBaseUrl": "`);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
describe('when angular.json have "options.styles" config', () => {
|
|
228
|
+
beforeEach(() => {
|
|
229
|
+
initMockWorkspace('with-options-styles');
|
|
230
|
+
});
|
|
231
|
+
it('should extends webpack base config', async () => {
|
|
232
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
233
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
234
|
+
expect(webpackFinalConfig).toEqual({
|
|
235
|
+
...baseWebpackConfig,
|
|
236
|
+
entry: [
|
|
237
|
+
...baseWebpackConfig.entry,
|
|
238
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.css'),
|
|
239
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
|
|
240
|
+
],
|
|
241
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
242
|
+
plugins: expect.anything(),
|
|
243
|
+
resolve: {
|
|
244
|
+
...baseWebpackConfig.resolve,
|
|
245
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
246
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
247
|
+
plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
|
|
248
|
+
},
|
|
249
|
+
resolveLoader: expect.anything(),
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
it('should set webpack "module.rules"', async () => {
|
|
253
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
254
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
255
|
+
const expectedRules = [
|
|
256
|
+
{
|
|
257
|
+
oneOf: [
|
|
258
|
+
{
|
|
259
|
+
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
260
|
+
use: expect.anything(),
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
264
|
+
use: expect.anything(),
|
|
265
|
+
},
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
{ use: expect.anything() },
|
|
269
|
+
];
|
|
270
|
+
expect(webpackFinalConfig.module.rules).toEqual([
|
|
271
|
+
{
|
|
272
|
+
test: /\.(?:css)$/i,
|
|
273
|
+
rules: expectedRules,
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
test: /\.(?:scss)$/i,
|
|
277
|
+
rules: expectedRules,
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
test: /\.(?:sass)$/i,
|
|
281
|
+
rules: expectedRules,
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
test: /\.(?:less)$/i,
|
|
285
|
+
rules: expectedRules,
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
test: /\.(?:styl)$/i,
|
|
289
|
+
rules: expectedRules,
|
|
290
|
+
},
|
|
291
|
+
{ mimetype: 'text/css', use: expect.anything() },
|
|
292
|
+
{ mimetype: 'text/x-scss', use: expect.anything() },
|
|
293
|
+
{ mimetype: 'text/x-sass', use: expect.anything() },
|
|
294
|
+
{ mimetype: 'text/x-less', use: expect.anything() },
|
|
295
|
+
{ mimetype: 'text/x-stylus', use: expect.anything() },
|
|
296
|
+
...baseWebpackConfig.module.rules,
|
|
297
|
+
]);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
describe('when angular.json haven\'t "options.tsConfig" config', () => {
|
|
301
|
+
beforeEach(() => {
|
|
302
|
+
initMockWorkspace('without-tsConfig');
|
|
303
|
+
});
|
|
304
|
+
it('throws error', async () => {
|
|
305
|
+
await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required options in project target. Check "tsConfig"');
|
|
306
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
describe('when is a nx with angular.json', () => {
|
|
310
|
+
beforeEach(() => {
|
|
311
|
+
initMockWorkspace('with-nx');
|
|
312
|
+
});
|
|
313
|
+
it('should extends webpack base config', async () => {
|
|
314
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
315
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
316
|
+
expect(webpackFinalConfig).toEqual({
|
|
317
|
+
...baseWebpackConfig,
|
|
318
|
+
entry: [
|
|
319
|
+
...baseWebpackConfig.entry,
|
|
320
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.css'),
|
|
321
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
|
|
322
|
+
],
|
|
323
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
324
|
+
plugins: expect.anything(),
|
|
325
|
+
resolve: {
|
|
326
|
+
...baseWebpackConfig.resolve,
|
|
327
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
328
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
329
|
+
plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
|
|
330
|
+
},
|
|
331
|
+
resolveLoader: expect.anything(),
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
it('should set webpack "module.rules"', async () => {
|
|
335
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
336
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
337
|
+
const expectedRules = [
|
|
338
|
+
{
|
|
339
|
+
oneOf: [
|
|
340
|
+
{
|
|
341
|
+
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
342
|
+
use: expect.anything(),
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
346
|
+
use: expect.anything(),
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
},
|
|
350
|
+
{ use: expect.anything() },
|
|
351
|
+
];
|
|
352
|
+
expect(webpackFinalConfig.module.rules).toEqual([
|
|
353
|
+
{
|
|
354
|
+
test: /\.(?:css)$/i,
|
|
355
|
+
rules: expectedRules,
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
test: /\.(?:scss)$/i,
|
|
359
|
+
rules: expectedRules,
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
test: /\.(?:sass)$/i,
|
|
363
|
+
rules: expectedRules,
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
test: /\.(?:less)$/i,
|
|
367
|
+
rules: expectedRules,
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
test: /\.(?:styl)$/i,
|
|
371
|
+
rules: expectedRules,
|
|
372
|
+
},
|
|
373
|
+
{ mimetype: 'text/css', use: expect.anything() },
|
|
374
|
+
{ mimetype: 'text/x-scss', use: expect.anything() },
|
|
375
|
+
{ mimetype: 'text/x-sass', use: expect.anything() },
|
|
376
|
+
{ mimetype: 'text/x-less', use: expect.anything() },
|
|
377
|
+
{ mimetype: 'text/x-stylus', use: expect.anything() },
|
|
378
|
+
...baseWebpackConfig.module.rules,
|
|
379
|
+
]);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
describe('when is a nx with workspace.json', () => {
|
|
383
|
+
beforeEach(() => {
|
|
384
|
+
initMockWorkspace('with-nx-workspace');
|
|
385
|
+
});
|
|
386
|
+
it('should extends webpack base config', async () => {
|
|
387
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
388
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
389
|
+
expect(webpackFinalConfig).toEqual({
|
|
390
|
+
...baseWebpackConfig,
|
|
391
|
+
entry: [
|
|
392
|
+
...baseWebpackConfig.entry,
|
|
393
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.css'),
|
|
394
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.scss'),
|
|
395
|
+
],
|
|
396
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
397
|
+
plugins: expect.anything(),
|
|
398
|
+
resolve: {
|
|
399
|
+
...baseWebpackConfig.resolve,
|
|
400
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
401
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
402
|
+
plugins: expect.arrayContaining([
|
|
403
|
+
expect.objectContaining({
|
|
404
|
+
absoluteBaseUrl: expect.any(String),
|
|
405
|
+
}),
|
|
406
|
+
]),
|
|
407
|
+
},
|
|
408
|
+
resolveLoader: expect.anything(),
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
it('should set webpack "module.rules"', async () => {
|
|
412
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
413
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
414
|
+
const expectedRules = [
|
|
415
|
+
{
|
|
416
|
+
oneOf: [
|
|
417
|
+
{
|
|
418
|
+
exclude: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
419
|
+
use: expect.anything(),
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
include: [`${workspaceRoot}/src/styles.css`, `${workspaceRoot}/src/styles.scss`],
|
|
423
|
+
use: expect.anything(),
|
|
424
|
+
},
|
|
425
|
+
],
|
|
426
|
+
},
|
|
427
|
+
{ use: expect.anything() },
|
|
428
|
+
];
|
|
429
|
+
expect(webpackFinalConfig.module.rules).toEqual([
|
|
430
|
+
{
|
|
431
|
+
test: /\.(?:css)$/i,
|
|
432
|
+
rules: expectedRules,
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
test: /\.(?:scss)$/i,
|
|
436
|
+
rules: expectedRules,
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
test: /\.(?:sass)$/i,
|
|
440
|
+
rules: expectedRules,
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
test: /\.(?:less)$/i,
|
|
444
|
+
rules: expectedRules,
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
test: /\.(?:styl)$/i,
|
|
448
|
+
rules: expectedRules,
|
|
449
|
+
},
|
|
450
|
+
{ mimetype: 'text/css', use: expect.anything() },
|
|
451
|
+
{ mimetype: 'text/x-scss', use: expect.anything() },
|
|
452
|
+
{ mimetype: 'text/x-sass', use: expect.anything() },
|
|
453
|
+
{ mimetype: 'text/x-less', use: expect.anything() },
|
|
454
|
+
{ mimetype: 'text/x-stylus', use: expect.anything() },
|
|
455
|
+
...baseWebpackConfig.module.rules,
|
|
456
|
+
]);
|
|
457
|
+
});
|
|
458
|
+
});
|
|
459
|
+
describe('when angular.json have only one lib project', () => {
|
|
460
|
+
beforeEach(() => {
|
|
461
|
+
initMockWorkspace('with-lib');
|
|
462
|
+
});
|
|
463
|
+
it('should extends webpack base config', async () => {
|
|
464
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
465
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
466
|
+
expect(webpackFinalConfig).toEqual({
|
|
467
|
+
...baseWebpackConfig,
|
|
468
|
+
entry: [...baseWebpackConfig.entry],
|
|
469
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
470
|
+
plugins: expect.anything(),
|
|
471
|
+
resolve: {
|
|
472
|
+
...baseWebpackConfig.resolve,
|
|
473
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
474
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
475
|
+
plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
|
|
476
|
+
},
|
|
477
|
+
resolveLoader: expect.anything(),
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
it('should set webpack "module.rules"', async () => {
|
|
481
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
482
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
483
|
+
const expectedRules = [
|
|
484
|
+
{
|
|
485
|
+
oneOf: [
|
|
486
|
+
{
|
|
487
|
+
exclude: [],
|
|
488
|
+
use: expect.anything(),
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
include: [],
|
|
492
|
+
use: expect.anything(),
|
|
493
|
+
},
|
|
494
|
+
],
|
|
495
|
+
},
|
|
496
|
+
{ use: expect.anything() },
|
|
497
|
+
];
|
|
498
|
+
expect(webpackFinalConfig.module.rules).toEqual([
|
|
499
|
+
{
|
|
500
|
+
test: /\.(?:css)$/i,
|
|
501
|
+
rules: expectedRules,
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
test: /\.(?:scss)$/i,
|
|
505
|
+
rules: expectedRules,
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
test: /\.(?:sass)$/i,
|
|
509
|
+
rules: expectedRules,
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
test: /\.(?:less)$/i,
|
|
513
|
+
rules: expectedRules,
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
test: /\.(?:styl)$/i,
|
|
517
|
+
rules: expectedRules,
|
|
518
|
+
},
|
|
519
|
+
{ mimetype: 'text/css', use: expect.anything() },
|
|
520
|
+
{ mimetype: 'text/x-scss', use: expect.anything() },
|
|
521
|
+
{ mimetype: 'text/x-sass', use: expect.anything() },
|
|
522
|
+
{ mimetype: 'text/x-less', use: expect.anything() },
|
|
523
|
+
{ mimetype: 'text/x-stylus', use: expect.anything() },
|
|
524
|
+
...baseWebpackConfig.module.rules,
|
|
525
|
+
]);
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
describe('when angular.json have some config', () => {
|
|
529
|
+
beforeEach(() => {
|
|
530
|
+
initMockWorkspace('some-config');
|
|
531
|
+
});
|
|
532
|
+
it('should log', async () => {
|
|
533
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
534
|
+
await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
535
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
|
|
536
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
|
|
537
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "foo-project:build" for configuring Storybook');
|
|
538
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
describe('with angularBrowserTarget option', () => {
|
|
542
|
+
beforeEach(() => {
|
|
543
|
+
initMockWorkspace('with-angularBrowserTarget');
|
|
544
|
+
options = { angularBrowserTarget: 'target-project:target-build' };
|
|
545
|
+
});
|
|
546
|
+
it('should log', async () => {
|
|
547
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
548
|
+
await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
549
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
|
|
550
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
|
|
551
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "target-project:target-build" for configuring Storybook');
|
|
552
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
describe('with angularBrowserTarget option with configuration', () => {
|
|
556
|
+
beforeEach(() => {
|
|
557
|
+
initMockWorkspace('with-angularBrowserTarget');
|
|
558
|
+
});
|
|
559
|
+
describe('when angular.json have the target without "configurations" section', () => {
|
|
560
|
+
beforeEach(() => {
|
|
561
|
+
options = {
|
|
562
|
+
angularBrowserTarget: 'no-confs-project:target-build:target-conf',
|
|
563
|
+
};
|
|
564
|
+
});
|
|
565
|
+
it('throws error', async () => {
|
|
566
|
+
await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing "configurations" section in project target');
|
|
567
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
describe('when angular.json have the target without required configuration', () => {
|
|
571
|
+
beforeEach(() => {
|
|
572
|
+
options = {
|
|
573
|
+
angularBrowserTarget: 'no-target-conf-project:target-build:target-conf',
|
|
574
|
+
};
|
|
575
|
+
});
|
|
576
|
+
it('throws error', async () => {
|
|
577
|
+
await expect(() => (0, framework_preset_angular_cli_1.webpackFinal)(newWebpackConfiguration(), options)).rejects.toThrowError('Missing required configuration in project target. Check "target-conf"');
|
|
578
|
+
expect(node_logger_1.logger.error).toHaveBeenCalledWith(`=> Could not get angular cli webpack config`);
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
describe('when angular.json have the target with required configuration', () => {
|
|
582
|
+
beforeEach(() => {
|
|
583
|
+
options = {
|
|
584
|
+
angularBrowserTarget: 'target-project:target-build:target-conf',
|
|
585
|
+
};
|
|
586
|
+
});
|
|
587
|
+
it('should log', async () => {
|
|
588
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
589
|
+
await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
590
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
|
|
591
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
|
|
592
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using angular project "target-project:target-build:target-conf" for configuring Storybook');
|
|
593
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
|
|
594
|
+
});
|
|
595
|
+
it('should extends webpack base config', async () => {
|
|
596
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
597
|
+
const webpackFinalConfig = await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
598
|
+
expect(webpackFinalConfig).toEqual({
|
|
599
|
+
...baseWebpackConfig,
|
|
600
|
+
entry: [
|
|
601
|
+
...baseWebpackConfig.entry,
|
|
602
|
+
path_1.default.join(workspaceRoot, 'src', 'styles.css'),
|
|
603
|
+
],
|
|
604
|
+
module: { ...baseWebpackConfig.module, rules: expect.anything() },
|
|
605
|
+
plugins: expect.anything(),
|
|
606
|
+
resolve: {
|
|
607
|
+
...baseWebpackConfig.resolve,
|
|
608
|
+
modules: expect.arrayContaining(baseWebpackConfig.resolve.modules),
|
|
609
|
+
// the base resolve.plugins are not kept 🤷♂️
|
|
610
|
+
plugins: expect.not.arrayContaining(baseWebpackConfig.resolve.plugins),
|
|
611
|
+
},
|
|
612
|
+
resolveLoader: expect.anything(),
|
|
613
|
+
});
|
|
614
|
+
});
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
describe('with only tsConfig option', () => {
|
|
618
|
+
beforeEach(() => {
|
|
619
|
+
initMockWorkspace('without-projects-entry');
|
|
620
|
+
options = {
|
|
621
|
+
tsConfig: 'projects/pattern-lib/tsconfig.lib.json',
|
|
622
|
+
angularBrowserTarget: null,
|
|
623
|
+
};
|
|
624
|
+
});
|
|
625
|
+
it('should log', async () => {
|
|
626
|
+
const baseWebpackConfig = newWebpackConfiguration();
|
|
627
|
+
await (0, framework_preset_angular_cli_1.webpackFinal)(baseWebpackConfig, options);
|
|
628
|
+
expect(node_logger_1.logger.info).toHaveBeenCalledTimes(3);
|
|
629
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(1, '=> Loading angular-cli config for angular lower than 12.2.0');
|
|
630
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(2, '=> Using default angular project with "tsConfig:projects/pattern-lib/tsconfig.lib.json"');
|
|
631
|
+
expect(node_logger_1.logger.info).toHaveBeenNthCalledWith(3, '=> Using angular-cli webpack config');
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
});
|
|
635
|
+
const newWebpackConfiguration = (transformer = (c) => c) => {
|
|
636
|
+
return transformer({
|
|
637
|
+
name: 'preview',
|
|
638
|
+
mode: 'development',
|
|
639
|
+
bail: false,
|
|
640
|
+
devtool: 'cheap-module-source-map',
|
|
641
|
+
entry: [
|
|
642
|
+
'/Users/joe/storybook/lib/core-server/dist/esm/globals/polyfills.js',
|
|
643
|
+
'/Users/joe/storybook/examples/angular-cli/.storybook/storybook-init-framework-entry.js',
|
|
644
|
+
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/common/config.js-generated-other-entry.js',
|
|
645
|
+
'/Users/joe/storybook/addons/docs/dist/esm/frameworks/angular/config.js-generated-other-entry.js',
|
|
646
|
+
'/Users/joe/storybook/addons/actions/dist/esm/preset/addDecorator.js-generated-other-entry.js',
|
|
647
|
+
'/Users/joe/storybook/addons/actions/dist/esm/preset/addArgs.js-generated-other-entry.js',
|
|
648
|
+
'/Users/joe/storybook/addons/links/dist/esm/preset/addDecorator.js-generated-other-entry.js',
|
|
649
|
+
'/Users/joe/storybook/addons/knobs/dist/esm/preset/addDecorator.js-generated-other-entry.js',
|
|
650
|
+
'/Users/joe/storybook/addons/backgrounds/dist/esm/preset/addDecorator.js-generated-other-entry.js',
|
|
651
|
+
'/Users/joe/storybook/addons/backgrounds/dist/esm/preset/addParameter.js-generated-other-entry.js',
|
|
652
|
+
'/Users/joe/storybook/addons/a11y/dist/esm/a11yRunner.js-generated-other-entry.js',
|
|
653
|
+
'/Users/joe/storybook/addons/a11y/dist/esm/a11yHighlight.js-generated-other-entry.js',
|
|
654
|
+
'/Users/joe/storybook/examples/angular-cli/.storybook/preview.ts-generated-config-entry.js',
|
|
655
|
+
'/Users/joe/storybook/examples/angular-cli/.storybook/generated-stories-entry.js',
|
|
656
|
+
'/Users/joe/storybook/node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined',
|
|
657
|
+
],
|
|
658
|
+
output: {
|
|
659
|
+
path: '/Users/joe/storybook/examples/angular-cli/node_modules/.cache/storybook/public',
|
|
660
|
+
filename: '[name].[hash].bundle.js',
|
|
661
|
+
publicPath: '',
|
|
662
|
+
},
|
|
663
|
+
plugins: [{ keepBasePlugin: true }],
|
|
664
|
+
module: {
|
|
665
|
+
rules: [{ keepBaseRule: true }],
|
|
666
|
+
},
|
|
667
|
+
resolve: {
|
|
668
|
+
extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json', '.cjs'],
|
|
669
|
+
modules: ['node_modules'],
|
|
670
|
+
mainFields: ['browser', 'main'],
|
|
671
|
+
alias: {
|
|
672
|
+
'@storybook/preview-api': '/Users/joe/storybook/lib/addons',
|
|
673
|
+
'@storybook/manager-api': '/Users/joe/storybook/lib/api',
|
|
674
|
+
'@storybook/channels': '/Users/joe/storybook/lib/channels',
|
|
675
|
+
'@storybook/channel-postmessage': '/Users/joe/storybook/lib/channel-postmessage',
|
|
676
|
+
'@storybook/components': '/Users/joe/storybook/ui/components',
|
|
677
|
+
'@storybook/core-events': '/Users/joe/storybook/lib/core-events',
|
|
678
|
+
'@storybook/router': '/Users/joe/storybook/lib/router',
|
|
679
|
+
'@storybook/theming': '/Users/joe/storybook/lib/theming',
|
|
680
|
+
'@storybook/client-api': '/Users/joe/storybook/lib/client-api',
|
|
681
|
+
'@storybook/client-logger': '/Users/joe/storybook/lib/client-logger',
|
|
682
|
+
react: '/Users/joe/storybook/node_modules/react',
|
|
683
|
+
'react-dom': '/Users/joe/storybook/node_modules/react-dom',
|
|
684
|
+
},
|
|
685
|
+
plugins: [{ keepBasePlugin: true }],
|
|
686
|
+
},
|
|
687
|
+
resolveLoader: { plugins: [] },
|
|
688
|
+
optimization: {
|
|
689
|
+
splitChunks: { chunks: 'all' },
|
|
690
|
+
runtimeChunk: true,
|
|
691
|
+
sideEffects: true,
|
|
692
|
+
usedExports: true,
|
|
693
|
+
concatenateModules: true,
|
|
694
|
+
minimizer: [],
|
|
695
|
+
},
|
|
696
|
+
performance: { hints: false },
|
|
697
|
+
});
|
|
698
|
+
};
|