Answer the question
In order to leave comments, you need to log in
Combining JS files, what's the best way?
The bottom line is, there is a JS file, it has a function, and another function that calls the first one, you need to divide this file into 2, one function in one, another in the other, all this is then run through webpack,
I tried it through include ( " ./qwerty.js"), does not work
If I specify several files in the Entry in webpack, then functions from different files are not visible.
I tried import {qwerty} from "./qwerty.js" also does not work, how to treat it?)
Answer the question
In order to leave comments, you need to log in
Using globals goes against the whole idea of webpack, but if it's such a heavy legacy,
see Global Exports - use exports-loader.
Try adding to webpack.config.js:
module: {
rules: [
{
test: require.resolve('qwerty.js'),
use: 'exports-loader?qwerty'
}
import { qwerty } from './qwerty.js';
If import {qwerty} from "./qwerty.js"
it doesn't work, then you forgot export function qwerty() {}
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question