From 9b25fadfab78b05579f37d165499e0d383894325 Mon Sep 17 00:00:00 2001 From: Joel Chen Date: Thu, 17 Sep 2020 10:10:56 -0700 Subject: [PATCH] fix: css module and loadable babel plugins needed in SSR --- .../xarc-app-dev/src/config/babel/babelrc.ts | 47 ++++++++++--------- samples/hapi-app/fyn-lock.yaml | 15 ++++-- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/packages/xarc-app-dev/src/config/babel/babelrc.ts b/packages/xarc-app-dev/src/config/babel/babelrc.ts index 14d12b079..ac16a87c9 100644 --- a/packages/xarc-app-dev/src/config/babel/babelrc.ts +++ b/packages/xarc-app-dev/src/config/babel/babelrc.ts @@ -49,9 +49,10 @@ const isTest = (BABEL_ENV || NODE_ENV) === "test"; const isNodeTarget = XARC_BABEL_TARGET === "node"; const basePlugins = [ - ...(!isNodeTarget && enableDynamicImport - ? ["@babel/plugin-syntax-dynamic-import", "@loadable/babel-plugin"] - : [false]), + !isNodeTarget && enableDynamicImport && "@babel/plugin-syntax-dynamic-import", + // add plugin for loadable component + // Note: this is needed for server side (node.js) also. + enableDynamicImport && "@loadable/babel-plugin", // allow decorators on class and method // Note: This must go before @babel/plugin-proposal-class-properties (enableTypeScript || proposalDecorators) && [ @@ -109,28 +110,28 @@ const plugins = basePlugins.concat( ] ], // css module support - !isNodeTarget && - enableCssModule && [ - [ - "babel-plugin-react-css-modules", - { - context: "./src", - generateScopedName: `${isProduction ? "" : "[name]__[local]___"}[hash:base64:5]`, - filetypes: { - ".scss": { - syntax: "postcss-scss", - plugins: ["postcss-nested"] - }, - ".styl": { - syntax: "sugarss" - }, - ".less": { - syntax: "postcss-less" - } + // Note: this is needed for server side (node.js) also. + enableCssModule && [ + [ + "babel-plugin-react-css-modules", + { + context: "./src", + generateScopedName: `${isProduction ? "" : "[name]__[local]___"}[hash:base64:5]`, + filetypes: { + ".scss": { + syntax: "postcss-scss", + plugins: ["postcss-nested"] + }, + ".styl": { + syntax: "sugarss" + }, + ".less": { + syntax: "postcss-less" } } - ] - ], + } + ] + ], !isNodeTarget && enableKarmaCov && [ getPluginFrom(["@xarc/opt-karma", "electrode-archetype-opt-karma"], "babel-plugin-istanbul") diff --git a/samples/hapi-app/fyn-lock.yaml b/samples/hapi-app/fyn-lock.yaml index 11cebf8b1..7fd463076 100644 --- a/samples/hapi-app/fyn-lock.yaml +++ b/samples/hapi-app/fyn-lock.yaml @@ -7744,8 +7744,8 @@ loader-utils: _: 'https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz' dependencies: big.js: ^5.2.2 - emojis-list: ^3.0.0 - json5: ^2.1.2 + emojis-list: ^2.0.0 + json5: ^1.0.1 1.4.0: $: sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== _: 'https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz' @@ -7875,6 +7875,11 @@ lodash.foreach: 4.5.0: $: sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= _: 'https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-4.5.0.tgz' + dependencies: + lodash._arrayeach: ^3.0.0 + lodash._baseeach: ^3.0.0 + lodash._bindcallback: ^3.0.0 + lodash.isarray: ^3.0.0 3.0.3: $: sha1-b9fvt5aRrs1n/erCdhyY5wHWw5o= _: 'https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-3.0.3.tgz' @@ -11246,9 +11251,9 @@ schema-utils: $: sha512-0ilKFI6QQF5nxDZLFn2dMjvc4hjg/Wkg7rHd3jK6/A4a1Hl9VFdQWvgB1UMGoU94pad1P/8N7fMcEnLnSiju8A== _: 'https://registry.npmjs.org/schema-utils/-/schema-utils-2.7.0.tgz' dependencies: - ajv: ^6.12.2 - ajv-keywords: ^3.4.1 - '@types/json-schema': ^7.0.4 + ajv: ^6.1.0 + ajv-errors: ^1.0.0 + ajv-keywords: ^3.1.0 1.0.0: $: sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g== _: 'https://registry.npmjs.org/schema-utils/-/schema-utils-1.0.0.tgz'