Answer the question
In order to leave comments, you need to log in
How to properly import a library in umd format?
There is a library that is built by webpack in umd format:
output: {
path: path.resolve(__dirname, '../build'),
filename: 'my-lib.min.js',
library: 'myLib',
globalObject: 'this',
libraryTarget: 'umd',
umdNamedDefine: true
},
<script src="my-lib.min.js"></script>
myLib.init();
Uncaught TypeError: Cannot set property 'myLib' of undefined
const myLib = require('./my-lib.min');
import './my-lib.min';
import { myLib } from './my-lib.min'
import myLib from './my-lib.min'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question