Skip to content

Commit

Permalink
feat(preact): replace react-refresh with @prefresh/webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
OSpoon committed Aug 10, 2024
1 parent 6f5416e commit dd7f477
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion programs/develop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"optionalDependencies": {
"@babel/core": "^7.24.9",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@prefresh/webpack": "^4.0.1",
"@svgr/webpack": "^8.1.0",
"@vue/compiler-sfc": "^3.4.34",
"babel-loader": "^9.1.3",
Expand All @@ -108,4 +109,4 @@
"vue-style-loader": "^4.1.3",
"vue-template-compiler": "^2.7.16"
}
}
}
15 changes: 7 additions & 8 deletions programs/develop/webpack/plugin-js-frameworks/js-tools/preact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,17 @@ export async function maybeUsePreact(
if (!isUsingPreact(projectPath)) return undefined

try {
require.resolve('react-refresh')
// Fast-refresh for Preact!
// https://github.com/preactjs/prefresh
require.resolve('@prefresh/webpack')
} catch (e) {
const reactDependencies = [
'react-refresh',
'@pmmmwh/react-refresh-webpack-plugin',
'@svgr/webpack',
'react-refresh-typescript'
const preactDependencies = [
'@prefresh/webpack'
]
const manifest = require(path.join(projectPath, 'manifest.json'))
const manifestName = manifest.name || 'Extension.js'

await installOptionalDependencies(manifestName, 'Preact', reactDependencies)
await installOptionalDependencies(manifestName, 'Preact', preactDependencies)

// The compiler will exit after installing the dependencies
// as it can't read the new dependencies without a restart.
Expand All @@ -68,7 +67,7 @@ export async function maybeUsePreact(
}

const preactPlugins: WebpackPluginInstance[] = [
new (require('@pmmmwh/react-refresh-webpack-plugin'))()
new (require('@prefresh/webpack'))()
]

return {
Expand Down

0 comments on commit dd7f477

Please sign in to comment.