I have created a custom package that includes a postinstall webpack script as specified in my package.json file:
"scripts": {
...
"postinstall": "webpack"
}
The webpack configuration looks like this:
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader')
module.exports = {
target: "node",
entry: {
Core: path.resolve(__dirname,'src/Core.ts')
},
devtool: 'inline-source-map',
output: {
filename: "[name].js",
chunkFilename: "[name].js",
libraryTarget: 'commonjs',
path: path.resolve(__dirname, "dist")
},
externals: {
canvas: "commonjs canvas",
},
resolve: {
extensions: [".js", ".ts"]
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.vue$/,
loader: 'vue-loader',
exclude: /node_modules/
},
{
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options:{
configFile: path.resolve(__dirname,"tsconfig.json")
}
}],
exclude: /node_modules/,
}
]
},
mode: 'development',
plugins: [
new VueLoaderPlugin(),
],
};
Everything works fine when I run the postscript within the package itself. However, when I try to include the package in another project, I encounter a typescript error related to the ts-loader
. Any insights on why this might be happening?
ERROR in ./src/Core.ts 32:0
Module parse failed: The keyword 'interface' is reserved (32:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders