Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 15 compatibility #19875

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 22 additions & 22 deletions code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@
"webpack": "5"
},
"devDependencies": {
"@angular-devkit/architect": "^0.1303.5",
"@angular-devkit/build-angular": "^13.3.5",
"@angular-devkit/core": "^13.3.5",
"@angular/cli": "^13.3.5",
"@angular/common": "^13.3.6",
"@angular/compiler": "^13.3.6",
"@angular/compiler-cli": "^13.3.6",
"@angular/core": "^13.3.6",
"@angular/forms": "^13.3.6",
"@angular/platform-browser": "^13.3.6",
"@angular/platform-browser-dynamic": "^13.3.6",
"@angular-devkit/architect": "^0.1500.0",
"@angular-devkit/build-angular": "^15.0.0",
"@angular-devkit/core": "^15.0.0",
"@angular/cli": "^15.0.0",
"@angular/common": "^15.0.0",
"@angular/compiler": "^15.0.0",
"@angular/compiler-cli": "^15.0.0",
"@angular/core": "^15.0.0",
"@angular/forms": "^15.0.0",
"@angular/platform-browser": "^15.0.0",
"@angular/platform-browser-dynamic": "^15.0.0",
"@nrwl/workspace": "14.6.1",
"@types/rimraf": "^3.0.2",
"@types/tmp": "^0.2.3",
Expand All @@ -91,17 +91,17 @@
"zone.js": "^0.11.0"
},
"peerDependencies": {
"@angular-devkit/architect": ">=0.1300.0",
"@angular-devkit/build-angular": ">=13.0.0",
"@angular-devkit/core": ">=13.0.0",
"@angular/cli": ">=13.0.0",
"@angular/common": ">=13.0.0",
"@angular/compiler": ">=13.0.0",
"@angular/compiler-cli": ">=13.0.0",
"@angular/core": ">=13.0.0",
"@angular/forms": ">=13.0.0",
"@angular/platform-browser": ">=13.0.0",
"@angular/platform-browser-dynamic": ">=13.0.0",
"@angular-devkit/architect": ">=0.1500.0",
"@angular-devkit/build-angular": ">=15.0.0",
"@angular-devkit/core": ">=15.0.0",
"@angular/cli": ">=15.0.0",
"@angular/common": ">=15.0.0",
"@angular/compiler": ">=15.0.0",
"@angular/compiler-cli": ">=15.0.0",
"@angular/core": ">=15.0.0",
"@angular/forms": ">=15.0.0",
"@angular/platform-browser": ">=15.0.0",
"@angular/platform-browser-dynamic": ">=15.0.0",
Comment on lines +94 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this works...
I assume we're going to have to think about how to make this backwards compatible?

"@babel/core": "*",
"@nrwl/workspace": "14.6.1",
"rxjs": "^6.0.0 || ^7.4.0",
Expand Down
8 changes: 2 additions & 6 deletions code/frameworks/angular/src/builders/build-storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { CLIOptions } from '@storybook/types';
import { catchError, map, mapTo, switchMap } from 'rxjs/operators';
import { sync as findUpSync } from 'find-up';
import { sync as readUpSync } from 'read-pkg-up';
import {
BrowserBuilderOptions,
ExtraEntryPoint,
StylePreprocessorOptions,
} from '@angular-devkit/build-angular';
import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular';

import { buildStaticStandalone } from '@storybook/core-server';
import { StandaloneOptions } from '../utils/standalone-options';
Expand All @@ -27,7 +23,7 @@ export type StorybookBuilderOptions = JsonObject & {
tsConfig?: string;
compodoc: boolean;
compodocArgs: string[];
styles?: ExtraEntryPoint[];
styles?: BrowserBuilderOptions['styles'];
Copy link
Member

@ndelangen ndelangen Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're on the right track.. in my investigation I also landed on some styles.entry/runtime being the source of the problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that this file: runtime~styles.iframe.bundle.js ran into this stack trace:

./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined (vendors-node_modules_angular-devkit_build-angular_node_modules_css-loader_dist_runtime_api_js-dbea25.iframe.bundle.js:169259)
__webpack_require__ (runtime~styles.iframe.bundle.js:28)
__webpack_exec__ (main.iframe.bundle.js:1854)
(anonymous) (main.iframe.bundle.js:1855)
__webpack_require__.O (runtime~styles.iframe.bundle.js:72)
(anonymous) (main.iframe.bundle.js:1856)
webpackJsonpCallback (runtime~styles.iframe.bundle.js:1077)
(anonymous) (runtime~styles.iframe.bundle.js:1091)
(anonymous) (runtime~styles.iframe.bundle.js:1093)
(anonymous) (runtime~styles.iframe.bundle.js:1099)

And the code that was breaking looked like this:

/***/ "./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined":
/*!************************************************************************************************!*\
  !*** ./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined ***!
  \************************************************************************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

var __resourceQuery = "?reload=true&quiet=false&noInfo=undefined";
/* module decorator */ module = __webpack_require__.nmd(module);
/*eslint-env browser*/
/*global __resourceQuery __webpack_public_path__*/

var options = {
  path: '/__webpack_hmr',
  timeout: 20 * 1000,
  overlay: true,
  reload: false,
  log: true,
  warn: true,
  name: '',
  autoConnect: true,
  overlayStyles: {},
  overlayWarnings: false,
  ansiColors: {}
};
if (true) {
  var overrides = Object.fromEntries(new URLSearchParams(__resourceQuery.slice(1)));
  setOverrides(overrides);
}
if (typeof window === 'undefined') {
  // do nothing
} else if (typeof window.EventSource === 'undefined') {
  console.warn("webpack-hot-middleware's client requires EventSource to work. " + 'You should include a polyfill if you want to support this browser: ' + 'https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events#Tools');
} else {
  if (options.autoConnect) {
    connect();
  }
}

failing on:

__webpack_require__.nmd

This error happened:

TypeError: __webpack_require__.nmd is not a function
    at ./node_modules/webpack-hot-middleware/client.js?reload=true&quiet=false&noInfo=undefined (vendors-node_modules_angular-devkit_build-angular_node_modules_css-loader_dist_runtime_api_js-dbea25.iframe.bundle.js:169260:53)
    at __webpack_require__ (runtime~styles.iframe.bundle.js:28:33)
    at __webpack_exec__ (main.iframe.bundle.js:1854:48)
    at main.iframe.bundle.js:1855:148
    at __webpack_require__.O (runtime~styles.iframe.bundle.js:72:23)
    at main.iframe.bundle.js:1856:56
    at webpackJsonpCallback (runtime~styles.iframe.bundle.js:1077:39)
    at Array.forEach (<anonymous>)
    at runtime~styles.iframe.bundle.js:1091:31
    at runtime~styles.iframe.bundle.js:1093:13

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2022-11-17 at 17 20 44

Screenshot 2022-11-17 at 17 21 07

stylePreprocessorOptions?: StylePreprocessorOptions;
} & Pick<
// makes sure the option exists
Expand Down
8 changes: 2 additions & 6 deletions code/frameworks/angular/src/builders/start-storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import {
targetFromTargetString,
} from '@angular-devkit/architect';
import { JsonObject } from '@angular-devkit/core';
import {
BrowserBuilderOptions,
ExtraEntryPoint,
StylePreprocessorOptions,
} from '@angular-devkit/build-angular';
import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular';
import { from, Observable, of } from 'rxjs';
import { CLIOptions } from '@storybook/types';
import { map, switchMap, mapTo } from 'rxjs/operators';
Expand All @@ -27,7 +23,7 @@ export type StorybookBuilderOptions = JsonObject & {
tsConfig?: string;
compodoc: boolean;
compodocArgs: string[];
styles?: ExtraEntryPoint[];
styles?: BrowserBuilderOptions['styles'];
stylePreprocessorOptions?: StylePreprocessorOptions;
} & Pick<
// makes sure the option exists
Expand Down
4 changes: 2 additions & 2 deletions code/frameworks/angular/src/server/preset-options.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Options as CoreOptions } from '@storybook/types';

import { BuilderContext } from '@angular-devkit/architect';
import { ExtraEntryPoint, StylePreprocessorOptions } from '@angular-devkit/build-angular';
import { BrowserBuilderOptions, StylePreprocessorOptions } from '@angular-devkit/build-angular';

export type PresetOptions = CoreOptions & {
/* Allow to get the options of a targeted "browser builder" */
angularBrowserTarget?: string | null;
/* Defined set of options. These will take over priority from angularBrowserTarget options */
angularBuilderOptions?: {
styles?: ExtraEntryPoint[];
styles?: BrowserBuilderOptions['styles'];
stylePreprocessorOptions?: StylePreprocessorOptions;
};
/* Angular context from builder */
Expand Down
2 changes: 1 addition & 1 deletion code/lib/builder-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"util-deprecate": "^1.0.2",
"webpack": "5",
"webpack-dev-middleware": "^5.3.1",
"webpack-hot-middleware": "^2.25.1",
"webpack-hot-middleware": "^2.25.3",
"webpack-virtual-modules": "^0.4.3"
},
"devDependencies": {
Expand Down