From 7164ef595147d997068b953d0e8bd19add0db5f9 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Fri, 13 Jun 2025 23:28:57 +0530 Subject: Using es-modules for webpack configuration. --- .../create-manifest-webpack-plugin/index.js | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'config/webpack/plugins/create-manifest-webpack-plugin') diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index 330c22f..2c9ab8e 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -1,10 +1,15 @@ -const { sources } = require("webpack"); -const path = require("path"); - -const { getScriptRuntimeFromType } = webpackRequire("utils/script-runtime"); -const { getFileName } = webpackRequire("utils/build-file"); -const scripts = webpackRequire("utils/scripts"); -const manifest = webpackRequire("plugins/create-manifest-webpack-plugin/manifest-template.json"); +import webpack from "webpack"; +import path from "path"; +import fs from "fs"; + +import { getScriptRuntimeFromType } from "../../utils/script-runtime.js"; +import { getFileName } from "../../utils/build-file.js"; +import scripts from "../../utils/scripts.js"; +const manifest = JSON.parse( + fs.readFileSync( + path.resolve("config/webpack/plugins/create-manifest-webpack-plugin/manifest-template.json"), + ), +); class CreateManifestPlugin { constructor({ sharedModulesImportedCount, injectedSharedModulesImportedCount, sortedSharedModules }) { @@ -21,7 +26,7 @@ class CreateManifestPlugin { stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL }, assets => { - manifest.version = require(path.resolve(ROOT_DIR, "package.json")).version; + manifest.version = JSON.parse(fs.readFileSync((path.resolve(ROOT_DIR, "package.json")))).version; manifest.content_scripts = []; let resources = []; @@ -101,7 +106,7 @@ class CreateManifestPlugin { compilation.emitAsset( "manifest.json", - new sources.RawSource( + new webpack.sources.RawSource( JSON.stringify( manifest, undefined, @@ -117,4 +122,4 @@ class CreateManifestPlugin { } } -module.exports = CreateManifestPlugin; +export default CreateManifestPlugin; -- cgit v1.2.3