I have a Typescript function that I've developed and would like to package it as a library.
To transpile the .ts files into .js files, I am using Laravel Mix and babel ts loader.
However, despite finding the file, I am unable to use the functions:
<script type="module">
import getCardInfo from '/js/main.js';
console.log(getCardInfo)
</script>
An error message is displayed stating:
The requested module '/js/main.js' does not provide an export named 'default'
The content of resources/cardActions.ts is as follows:
export default function getCardInfo() {
console.log("getting card info");
}
This is how my webpack.mix.js looks like:
mix.ts('resources/cardActions.ts', 'public/js')
mix.webpackConfig({
entry: './public/js/cardActions.js',
output: {
path: path.resolve(__dirname, 'public'),
filename: 'js/main.js',
libraryTarget: 'window'
}
})