I have 2 legacy JS files, which I do not want to change. For that reason I want to use exports-loader and imports-loader
File B-legacy needs the global var GLOB from File A-legacy
My webpack.config.js results in
rules: [
{ test: /\.ts$/, use: 'ts-loader' }, // Typescript file loader;
{
test: path.resolve(__dirname, '../Scripts/legacy/A-legacy'),
use: 'exports-loader?GLOB'
},
{
test: path.resolve(__dirname, '../Scripts/legacy/B-legacy'),
use: 'imports-loader?GLOB'
}
],
For my understanding that should work. I'm exporting the GLOB var in A-legacy and want to import it to B-legacy.
But building it gives the following error:
ERROR in ./Scripts/legacy/B-legacy.js Module not found: Error: Can't resolve 'GLOB' in 'C:\anypath\Scripts\legacy' @ ./Scripts/legacy/A-legacy.js 2:11-26
I've already tried to add enforce: "pre" to exports-loader rule. But that doesn't change anything