Skip to content

Commit

Permalink
fix(gatsby-plugin-preact): fix preact alias (#35156)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet authored Mar 18, 2022
1 parent ba9fec6 commit b13ddff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
24 changes: 8 additions & 16 deletions packages/gatsby-plugin-preact/src/__tests__/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ describe(`gatsby-plugin-preact`, () => {
plugins: expect.arrayContaining([expect.any(PreactRefreshPlugin)]),
resolve: {
alias: {
react: expect.stringContaining(path.join(`preact`, `compat`)),
"react-dom": expect.stringContaining(path.join(`preact`, `compat`)),
"react-dom/server": expect.stringContaining(
path.join(`preact`, `compat`, `server`)
),
"react/jsx-runtime": expect.stringContaining(
path.join(`preact`, `jsx-runtime`)
),
react: `preact/compat`,
"react-dom/test-utils": `preact/test-utils`,
"react-dom": `preact/compat`,
"react/jsx-runtime": `preact/jsx-runtime`,
},
},
})
Expand Down Expand Up @@ -100,14 +96,10 @@ describe(`gatsby-plugin-preact`, () => {
plugins: [],
resolve: {
alias: {
react: expect.stringContaining(path.join(`preact`, `compat`)),
"react-dom": expect.stringContaining(path.join(`preact`, `compat`)),
"react-dom/server": expect.stringContaining(
path.join(`preact`, `compat`, `server`)
),
"react/jsx-runtime": expect.stringContaining(
path.join(`preact`, `jsx-runtime`)
),
react: `preact/compat`,
"react-dom/test-utils": `preact/test-utils`,
"react-dom": `preact/compat`,
"react/jsx-runtime": `preact/jsx-runtime`,
},
},
})
Expand Down
12 changes: 4 additions & 8 deletions packages/gatsby-plugin-preact/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,13 @@ export function onCreateWebpackConfig({ stage, actions, getConfig }) {

actions.replaceWebpackConfig(webpackConfig)

const extension =
stage === `build-javascript` || stage === `develop` ? `.module.js` : `.js`
actions.setWebpackConfig({
resolve: {
alias: {
react: require.resolve(`preact/compat`).replace(`.js`, extension),
"react-dom/server": require.resolve(`preact/compat/server`),
"react-dom": require.resolve(`preact/compat`).replace(`.js`, extension),
"react/jsx-runtime": require
.resolve(`preact/jsx-runtime`)
.replace(`.js`, extension),
react: `preact/compat`,
"react-dom/test-utils": `preact/test-utils`,
"react-dom": `preact/compat`,
"react/jsx-runtime": `preact/jsx-runtime`,
},
},
plugins: webpackPlugins,
Expand Down

0 comments on commit b13ddff

Please sign in to comment.