From 5e71cd2c6bb45e10ab8df9dd0dfd9547521e8b8b Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Thu, 4 Aug 2022 02:44:42 +0800 Subject: [PATCH] chore: make webpack call compactible with 4 and 5 --- package.json | 1 + pnpm-lock.yaml | 2 ++ test/unit-tests/resolve-id/resolve-id.test.ts | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fab1107..d64b271 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "fs-extra": "^10.1.0", "jiti": "^1.14.0", "magic-string": "^0.26.2", + "picocolors": "^1.0.0", "rollup": "^2.77.2", "tsup": "^6.2.0", "typescript": "^4.7.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 800e5ea..8050e79 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,6 +19,7 @@ specifiers: fs-extra: ^10.1.0 jiti: ^1.14.0 magic-string: ^0.26.2 + picocolors: ^1.0.0 rollup: ^2.77.2 tsup: ^6.2.0 typescript: ^4.7.4 @@ -52,6 +53,7 @@ devDependencies: fs-extra: 10.1.0 jiti: 1.14.0 magic-string: 0.26.2 + picocolors: 1.0.0 rollup: 2.77.2 tsup: 6.2.0_typescript@4.7.4 typescript: 4.7.4 diff --git a/test/unit-tests/resolve-id/resolve-id.test.ts b/test/unit-tests/resolve-id/resolve-id.test.ts index 4f26c17..2b934e5 100644 --- a/test/unit-tests/resolve-id/resolve-id.test.ts +++ b/test/unit-tests/resolve-id/resolve-id.test.ts @@ -2,7 +2,7 @@ import * as path from 'path' import { it, describe, expect, vi, afterEach, Mock } from 'vitest' import * as vite from 'vite' import * as rollup from 'rollup' -import { webpack } from 'webpack' +import * as webpack from 'webpack' import * as esbuild from 'esbuild' import { createUnplugin, UnpluginOptions } from '../../../src' @@ -83,7 +83,7 @@ describe('resolveId hook', () => { const plugin = createUnpluginWithCallback(mockResolveIdHook).webpack await new Promise((resolve) => { - webpack( + (webpack.webpack || webpack)( { entry: path.resolve(__dirname, 'test-src/entry.js'), plugins: [plugin()]