У меня есть одна библиотека, экспортированная как var (MyTestLib)
Index. js
module.exports = { Hello: "Herere" };
Webpack. config. js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const sourcePath = path.join(__dirname, "./src");
const outPath = path.join(__dirname, "./dist");
module.exports = {
context: sourcePath,
entry: {
"test": "./index.js",
},
target: "web",
output: {
path: outPath,
publicPath: "/",
filename: "[name].js",
library: "MyTestLib",
libraryTarget: "var",
},
module: {
rules: [
{
test: /\.css$/,
loaders: ["style-loader", "css-loader?modules"],
},
{
test: /\.(js?|jsx)$/,
use: ["babel-loader"],
},
],
},
resolve: {
extensions: [".js", ".jsx"],
},
devServer: {
contentBase: path.resolve(__dirname, "dist"),
port: 9000,
},
};
Теперь я пытаюсь использовать тот же Lib в другом приложении MyTestApp-Parent Как показано ниже
import * as tmp from "my-test-app";
console.log("tmp===> ", tmp);
он возвращает пустой объект ({} ). Что я тут не так делаю?