(
/** @type {string} */ entry,
/** @type {(stats: import("../types").StatsCompilation) => void} */ onSuccess,
/** @type {(err: Error) => void} */ onError
)
| 21 | ); |
| 22 | |
| 23 | function compile( |
| 24 | /** @type {string} */ entry, |
| 25 | /** @type {(stats: import("../types").StatsCompilation) => void} */ onSuccess, |
| 26 | /** @type {(err: Error) => void} */ onError |
| 27 | ) { |
| 28 | const webpack = require(".."); |
| 29 | |
| 30 | const options = webpack.config.getNormalizedWebpackOptions({}); |
| 31 | options.cache = { |
| 32 | type: "filesystem", |
| 33 | cacheDirectory: path.join(tempFixturePath, "cache") |
| 34 | }; |
| 35 | options.entry = /** @type {import("../types").EntryNormalized} */ ( |
| 36 | /** @type {unknown} */ (entry) |
| 37 | ); |
| 38 | options.context = path.join(__dirname, "fixtures"); |
| 39 | options.output.path = path.join(tempFixturePath, "dist"); |
| 40 | options.output.filename = "bundle.js"; |
| 41 | options.output.pathinfo = true; |
| 42 | options.module = |
| 43 | /** @type {import("../types").WebpackOptionsNormalized["module"]} */ ( |
| 44 | /** @type {unknown} */ ({ |
| 45 | rules: [ |
| 46 | { |
| 47 | test: /\.svg$/, |
| 48 | type: "asset/resource", |
| 49 | use: { |
| 50 | loader: require.resolve("./fixtures/empty-svg-loader") |
| 51 | } |
| 52 | } |
| 53 | ] |
| 54 | }) |
| 55 | ); |
| 56 | |
| 57 | const isBigIntSupported = typeof BigInt !== "undefined"; |
| 58 | const isErrorCaseSupported = |
| 59 | typeof new Error("test", { cause: new Error("cause") }).cause !== |
| 60 | "undefined"; |
| 61 | const isAggregateErrorSupported = typeof AggregateError !== "undefined"; |
| 62 | |
| 63 | options.plugins = [ |
| 64 | { |
| 65 | apply(compiler) { |
| 66 | const name = "TestCachePlugin"; |
| 67 | |
| 68 | compiler.hooks.thisCompilation.tap(name, (compilation) => { |
| 69 | compilation.hooks.processAssets.tapPromise( |
| 70 | { |
| 71 | name, |
| 72 | stage: |
| 73 | compiler.webpack.Compilation |
| 74 | .PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE |
| 75 | }, |
| 76 | async () => { |
| 77 | const cache = compilation.getCache(name); |
| 78 | const ident = "test.ext"; |
| 79 | const cacheItem_ = cache.getItemCache(ident, null); |
| 80 | const cacheItem = |
no test coverage detected