Home > Mobile >  Can webpack generate a module with exports?
Can webpack generate a module with exports?

Time:11-22

I was able to create a webpack config to bundle few modules. The generated bundle looks as follows:

/* harmony default export */ const subscriptions = ({
... // my stuff
/******/ })()
;

I'd like to test the generated bundle so i need to have some exports instead of self-invoking function to import it in the test and make sure everything is aliased as expected (so i have correct resolve.alias webpack section in my config), smth similar to the following:

export const subscriptions = ...

Is it possible to instruct webpack to generate it as a module?

CodePudding user response:

Did it with the following webpack config:

    ...
    output: {
      ...
      library: {type: "module"}
    },
    experiments: {
      outputModule: true
    },
    ...
  • Related