How to force a dependency to be bundled #19183
|
Hi, I'm using webpack to bundle my app. This app is instrumented with a library which contains this code : import { register } from 'node:module';
import * as importInTheMiddle from 'import-in-the-middle';
const { registerOptions, waitForAllMessagesAcknowledged } =
importInTheMiddle.createAddHookMessageChannel();
register('import-in-the-middle/hook.mjs', import.meta.url, registerOptions);
await waitForAllMessagesAcknowledged();When i run webpack, everything is working fine, but webpack does not include How to specify to webpack to include this file in the bundle ? Regards |
Answered by
alexander-akait
Feb 4, 2025
Replies: 2 comments 1 reply
|
You need to create a simple custom plugin and rewrite string, webpack doesn't provide such things our of box |
0 replies
|
Thanks for answering so fast ! Ok then i will implement this. Can you share to me a link to a documentation for this ? Or any webpack plugin which can look like what i'm looking for ? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can look at https://www.npmjs.com/package/webpack-plugin-replace or https://www.npmjs.com/package/string-replace-webpack-plugin. Or you can look at their source code and implement an own simple solution.
Alternative you can create a small Node.js script which will replace your string on generated and run it after webpack