From a8498a174ff60e404ebe80e45582cc386268524f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Fri, 24 May 2019 07:43:14 +0200 Subject: [PATCH 1/2] Uses require.resolve on setBabelPreset --- packages/gatsby-plugin-emotion/src/gatsby-node.js | 2 +- packages/gatsby-plugin-flow/src/gatsby-node.js | 2 +- packages/gatsby-plugin-glamor/src/gatsby-node.js | 4 ++-- packages/gatsby-plugin-typescript/src/gatsby-node.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-plugin-emotion/src/gatsby-node.js b/packages/gatsby-plugin-emotion/src/gatsby-node.js index a9222680452af..67895e007ae19 100644 --- a/packages/gatsby-plugin-emotion/src/gatsby-node.js +++ b/packages/gatsby-plugin-emotion/src/gatsby-node.js @@ -1,6 +1,6 @@ export const onCreateBabelConfig = ({ actions }, pluginOptions) => { actions.setBabelPreset({ - name: `@emotion/babel-preset-css-prop`, + name: require.resolve(`@emotion/babel-preset-css-prop`), options: { sourceMap: process.env.NODE_ENV !== `production`, autoLabel: process.env.NODE_ENV !== `production`, diff --git a/packages/gatsby-plugin-flow/src/gatsby-node.js b/packages/gatsby-plugin-flow/src/gatsby-node.js index b29f8a0eea2b3..3941503b49c2b 100644 --- a/packages/gatsby-plugin-flow/src/gatsby-node.js +++ b/packages/gatsby-plugin-flow/src/gatsby-node.js @@ -1,5 +1,5 @@ export const onCreateBabelConfig = ({ actions }, pluginOptions) => { actions.setBabelPreset({ - name: `@babel/preset-flow`, + name: require.resolve(`@babel/preset-flow`), }) } diff --git a/packages/gatsby-plugin-glamor/src/gatsby-node.js b/packages/gatsby-plugin-glamor/src/gatsby-node.js index 28c76f92252f1..0c0ab3f5d3516 100644 --- a/packages/gatsby-plugin-glamor/src/gatsby-node.js +++ b/packages/gatsby-plugin-glamor/src/gatsby-node.js @@ -11,10 +11,10 @@ exports.onCreateWebpackConfig = ({ actions, plugins }) => // Add Glamor babel plugin exports.onCreateBabelConfig = ({ actions }) => { actions.setBabelPlugin({ - name: `glamor/babel-hoist`, + name: require.resolve(`glamor/babel-hoist`), }) actions.setBabelPreset({ - name: `@babel/preset-react`, + name: require.resolve(`@babel/preset-react`), options: { pragma: `Glamor.createElement`, }, diff --git a/packages/gatsby-plugin-typescript/src/gatsby-node.js b/packages/gatsby-plugin-typescript/src/gatsby-node.js index 7a1d7156443f7..e8abc45920a47 100644 --- a/packages/gatsby-plugin-typescript/src/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/gatsby-node.js @@ -2,7 +2,7 @@ const resolvableExtensions = () => [`.ts`, `.tsx`] function onCreateBabelConfig({ actions }, options) { actions.setBabelPreset({ - name: `@babel/preset-typescript`, + name: require.resolve(`@babel/preset-typescript`), options, }) } From 6c9a60169c4bd553b8e1050de91a678e3b91cd67 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Fri, 24 May 2019 14:40:54 +0200 Subject: [PATCH 2/2] adjust tests to pass with fully resolved path --- packages/gatsby-plugin-emotion/src/__tests__/gatsby-node.js | 6 +++--- packages/gatsby-plugin-flow/src/__tests__/gatsby-node.js | 2 +- .../gatsby-plugin-typescript/src/__tests__/gatsby-node.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/gatsby-plugin-emotion/src/__tests__/gatsby-node.js b/packages/gatsby-plugin-emotion/src/__tests__/gatsby-node.js index 04a2cfb646538..7cb5059370016 100644 --- a/packages/gatsby-plugin-emotion/src/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-emotion/src/__tests__/gatsby-node.js @@ -9,7 +9,7 @@ describe(`gatsby-plugin-emotion`, () => { expect(actions.setBabelPreset).toHaveBeenCalledTimes(1) expect(actions.setBabelPreset).toHaveBeenCalledWith({ - name: `@emotion/babel-preset-css-prop`, + name: expect.stringContaining(`@emotion/babel-preset-css-prop`), options: { sourceMap: true, autoLabel: true, @@ -25,7 +25,7 @@ describe(`gatsby-plugin-emotion`, () => { expect(actions.setBabelPreset).toHaveBeenCalledTimes(1) expect(actions.setBabelPreset).toHaveBeenCalledWith({ - name: `@emotion/babel-preset-css-prop`, + name: expect.stringContaining(`@emotion/babel-preset-css-prop`), options: { sourceMap: true, autoLabel: true, @@ -53,7 +53,7 @@ describe(`gatsby-plugin-emotion`, () => { expect(actions.setBabelPreset).toHaveBeenCalledTimes(1) expect(actions.setBabelPreset).toHaveBeenCalledWith({ - name: `@emotion/babel-preset-css-prop`, + name: expect.stringContaining(`@emotion/babel-preset-css-prop`), options: { sourceMap: false, autoLabel: false, diff --git a/packages/gatsby-plugin-flow/src/__tests__/gatsby-node.js b/packages/gatsby-plugin-flow/src/__tests__/gatsby-node.js index 18400c8f44000..c8f1d38426078 100644 --- a/packages/gatsby-plugin-flow/src/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-flow/src/__tests__/gatsby-node.js @@ -9,7 +9,7 @@ describe(`gatsby-plugin-flow`, () => { expect(actions.setBabelPreset).toHaveBeenCalledTimes(1) expect(actions.setBabelPreset).toHaveBeenCalledWith({ - name: `@babel/preset-flow`, + name: expect.stringContaining(`@babel/preset-flow`), }) }) }) diff --git a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js index 255676d8d1972..a26e4d904eba9 100644 --- a/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js +++ b/packages/gatsby-plugin-typescript/src/__tests__/gatsby-node.js @@ -21,7 +21,7 @@ describe(`gatsby-plugin-typescript`, () => { } onCreateBabelConfig({ actions }, options) expect(actions.setBabelPreset).toHaveBeenCalledWith({ - name: `@babel/preset-typescript`, + name: expect.stringContaining(`@babel/preset-typescript`), options, }) })