Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Jan 23, 2024
1 parent 74c538c commit 493d483
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ export default class EsbuildPlugin {
* Webpack 5: https://github.com/webpack/webpack/blob/v5.75.0/lib/SourceMapDevToolModuleOptionsPlugin.js#LL27
*/
let useSourceMap = false;

/**
* `finishModules` hook is called after all the `buildModule` hooks are called,
* which is where the `useSourceMap` flag is set
* https://webpack.js.org/api/compilation-hooks/#finishmodules
*/
compilation.hooks.finishModules.tap(
pluginName,
(modules) => {
Expand Down
23 changes: 12 additions & 11 deletions tests/specs/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,6 @@ export default testSuite(({ describe }, webpack: typeof webpack4 | typeof webpac
expect(exportedFunction('hello world')).toBe('hello world');
assertMinified(exportedFunction.toString());
});

test('can handle invalid webpack config', async () => {
await expect(build(
fixtures.blank,
(config) => {
config.entry = 'not-there.js';
configureEsbuildMinifyPlugin(config);
},
webpack,
)).resolves.toBeTruthy();
});
});

describe('CSS', ({ test }) => {
Expand Down Expand Up @@ -749,5 +738,17 @@ export default testSuite(({ describe }, webpack: typeof webpack4 | typeof webpac
expect(exportedFunction('hello world')).toBe('hello world');
assertMinified(exportedFunction.toString());
});

// https://github.com/privatenumber/esbuild-loader/issues/356
test('can handle empty modules set', async () => {
await expect(build(
fixtures.blank,
(config) => {
config.entry = 'not-there.js';
configureEsbuildMinifyPlugin(config);
},
webpack,
)).resolves.toBeTruthy();
});
});
});

0 comments on commit 493d483

Please sign in to comment.