From fb9b2b1d7b889d1d99b16cc76dd7408d01e2a323 Mon Sep 17 00:00:00 2001 From: Pete Miller Date: Thu, 13 Oct 2022 22:31:26 -0700 Subject: [PATCH] Storybook build has correct deps and works better with chrome://resources urls and stub plural_string_proxy.js.ts so it does not error --- .storybook/BUILD.gn | 7 +++++++ .../js/plural_string_proxy.js.ts | 16 ++++++++++++++++ .storybook/webpack.config.js | 2 +- BUILD.gn | 8 ++++---- 4 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 .storybook/chrome-resources-mock/js/plural_string_proxy.js.ts diff --git a/.storybook/BUILD.gn b/.storybook/BUILD.gn index 18ee304bb911..09924b57b12d 100644 --- a/.storybook/BUILD.gn +++ b/.storybook/BUILD.gn @@ -11,8 +11,15 @@ group("storybook") { # are disabled in a regular brave build due to build flags, # they will be generated before storybook is compiled. deps = [ + "//brave/components/brave_new_tab_ui:mojom_js", + "//brave/components/brave_shields/common:mojom_js", + "//brave/components/brave_today/common:mojom_js", "//brave/components/brave_vpn/mojom:mojom_js", "//brave/components/brave_wallet/common:mojom_js", + "//brave/components/speedreader/common:mojom_js", + "//mojo/public/js:bindings", + "//mojo/public/js:resources", + "//ui/webui/resources/js:cr.m", "//ui/webui/resources/js:modulize", "//ui/webui/resources/js:preprocess", ] diff --git a/.storybook/chrome-resources-mock/js/plural_string_proxy.js.ts b/.storybook/chrome-resources-mock/js/plural_string_proxy.js.ts new file mode 100644 index 000000000000..b47f1ac7c0ff --- /dev/null +++ b/.storybook/chrome-resources-mock/js/plural_string_proxy.js.ts @@ -0,0 +1,16 @@ +// Copyright (c) 2022 The Brave Authors. All rights reserved. +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// you can obtain one at http://mozilla.org/MPL/2.0/. + +let instance: PluralStringProxyImpl | null = null + +export class PluralStringProxyImpl { + static getInstance() { + return instance || (instance = new PluralStringProxyImpl()) + } + + getPluralString(key: string, count: number): Promise { + return Promise.resolve(`${key}(${count})`) + } +} diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index dd596e4c27d8..5429277294a9 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -90,7 +90,7 @@ module.exports = async ({ config, mode }) => { // build, but has previously made a Component build, then an outdated // version of a module will be used. Instead, accept a cli argument // or environment variable containing which build target to use. - ...getBuildOuptutPathList('gen/ui/webui/resources') + ...getBuildOuptutPathList('gen/ui/webui/resources/preprocessed') ] }, { diff --git a/BUILD.gn b/BUILD.gn index 5372051630f6..2a49077bd45e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -57,6 +57,10 @@ if (!is_ios) { deps += [ ":packed_resources" ] } } + + group("storybook") { + deps = [ "//brave/.storybook:storybook" ] + } } if (is_win) { @@ -542,10 +546,6 @@ group("tools") { } } -group("storybook") { - deps = [ "//brave/.storybook:storybook" ] -} - if (is_redirect_cc_build) { group("redirect_cc") { deps = [ "//brave/tools/redirect_cc" ]