diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 24af40eb6..fba55e6b6 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -39,6 +39,7 @@ "lodash": "^4.17.10", "mini-css-extract-plugin": "^1.3.2", "pkg-up": "^3.1.0", + "semver": "^7.3.5", "source-map-url": "^0.4.0", "style-loader": "^2.0.0", "terser": "^5.5.1", diff --git a/packages/webpack/src/ember-webpack.ts b/packages/webpack/src/ember-webpack.ts index 9f16e89ce..d2dc34445 100644 --- a/packages/webpack/src/ember-webpack.ts +++ b/packages/webpack/src/ember-webpack.ts @@ -26,6 +26,7 @@ import { HTMLEntrypoint } from './html-entrypoint'; import { StatSummary } from './stat-summary'; import crypto from 'crypto'; import type { HbsLoaderConfig } from '@embroider/hbs-loader'; +import semverSatisfies from 'semver/functions/satisfies'; const debug = makeDebug('embroider:debug'); @@ -83,6 +84,10 @@ const Webpack: Packager = class Webpack implements PackagerInstance { private consoleWrite: (msg: string) => void, options?: Options ) { + if (!semverSatisfies(webpack.version, '^5.0.0')) { + throw new Error(`@embroider/webpack requires webpack@^5.0.0, but found version ${webpack.version}`); + } + this.pathToVanillaApp = realpathSync(pathToVanillaApp); this.extraConfig = options?.webpackConfig; this.publicAssetURL = options?.publicAssetURL;