diff --git a/src/hooks.ts b/src/hooks.ts index 3dee3b1..f50f743 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -5,13 +5,15 @@ import { SyncWaterfallHook } from 'tapable'; import type { Compiler, Module, Compilation, LoaderContext } from 'webpack'; // Note: This was the old delcaration. It appears to be Webpack v3 compat. // const { RawSource } = (webpack as any).sources || require('webpack-sources'); -import { RawSource } from 'webpack-sources'; +import webpackSources from 'webpack-sources'; import type { EmitCountMap, InternalOptions } from './index.js'; import type { CompilationAsset, FileDescriptor } from './helpers.js'; import { generateManifest, reduceAssets, reduceChunk, transformFiles } from './helpers.js'; +const { RawSource } = webpackSources; + interface BeforeRunHookArgs { emitCountMap: EmitCountMap; manifestFileName: string; diff --git a/test/integration/usage.ts b/test/integration/usage.ts new file mode 100644 index 0000000..8dfbc61 --- /dev/null +++ b/test/integration/usage.ts @@ -0,0 +1,14 @@ +import { execSync } from 'node:child_process'; + +import test from '../helpers/ava-compat'; + +// make implicit dependency explicit: +import '../../src/index'; + +test.before(() => execSync('pnpm build')); + +test('can be used as documented', (t) => { + const readmeCode = "import { WebpackManifestPlugin } from 'webpack-manifest-plugin'"; + + t.deepEqual(execSync(`node -e "${readmeCode}"`, { encoding: 'utf-8' }), ''); +});