I’m able to use libraries with node like:
const API = require("api");
const Service = require("service");
however, when I bundle the js file with webpack, it doesn’t work and I need to change the way I require them to:
const { API } = require("api");
const Service = require("service").default;
This is my webpack.config.js
const path = require("path");
module.exports = {
entry: "./libs.js",
output: {
path: path.resolve(__dirname, "out"),
filename: "bundle.js",
library: "bundle",
libraryTarget: "var",
},
};
Is this expected or am I missing something?
thanks!