-1

I have a nodejs app which exports a function, using that function I want to retreive the resulted object and include it in the webpack bundle. I tried webpack magic comment webpackIgnore but it also ignores to include the function result in the bundle. Like following:

const getConfig = import('../interface' /* webpackIgnore: true */);
const config = getConfig();

What I need is the const config result included in the bundle. How can I do that?

Disclaimer: this example is just a quick random snippet made to show the point.

Sorin GFS
  • 477
  • 3
  • 18
  • You could write the config to a file and then `require("../theconfigfile.json")` so it will be included in your bundle. I don't think it's possible to evaluate the result of a method and include it in the webpack bundle. – Rick Oct 14 '22 at 11:09
  • @Rick I know how to include regular files, but here I need the result of a method. You're possibly right about not being possible but... I didn't lost my hope. Thank you. – Sorin GFS Oct 14 '22 at 11:27
  • 1
    You might want to look at https://stackoverflow.com/questions/55527419/how-can-i-evaluate-a-node-script-during-a-webpack-build-and-make-it-contents-ava – Rick Oct 14 '22 at 12:07

1 Answers1

-1

you syntax is wrong, using:

// commonjs
const getConfig = require("../interface");

or

// module
import getConfig from "../interface"

if interface file using export default

gungim
  • 1
  • Obviusly something is wrong, but this is not a solution to the question. The `getCOnfig` is proccessed without errors... – Sorin GFS Oct 14 '22 at 09:41