Answer the question
In order to leave comments, you need to log in
Typescript - how to create an import bundle without typescript?
All the best!
There is a typescript lib, let's call it my-sample-lib, that webpack builds. At the output, I want to get a bundle that can be either simply included in the <script> tag or imported into another assembly that does not use typescript:
// примерно так
import MySampleLib from 'vendor/my-sample-lib/dist/js/my-sample-lib.js'
window.MySampleLib = MySampleLib;
entry: {
'my-sample-lib': './src/index.ts',
},
output: {
filename: './dist/js/[name].js',
path: path.resolve( __dirname ),
}
import './scss/my-sample-lib/main.scss';
import MySampleLib from './ts/my-sample-lib';
export default MySampleLib;
output: {
filename: './dist/js/[name].js',
path: path.resolve( __dirname ),
library: 'MySampleLib',
libraryTarget: 'umd',
}
<script src="/dist/js/my-sample-lib.js'">
<script>
console.log( MySampleLib ); // {__esModule: true, default: ƒ}
</script>
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