Closed garyking closed 4 years ago
Okay, so I figured it out with the following nextron.config.js
file in the project root dir:
const path = require('path');
const cwd = process.cwd();
module.exports = {
webpack: (defaultConfig) =>
Object.assign(defaultConfig, {
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['@babel/preset-typescript'],
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
},
},
exclude: [/node_modules/, path.join(cwd, 'renderer')],
},
],
},
}),
};
Thanks for leaving these comments @garyking! This will hopefully help someone else and there may be some room for improvements to the Typescript handling.
I'm using the same stack, but had to add an additional plugin to nextron.config.js
:
const path = require('path');
const cwd = process.cwd();
module.exports = {
webpack: (defaultConfig) =>
Object.assign(defaultConfig, {
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['@babel/preset-typescript'],
plugins: [
"babel-plugin-transform-typescript-metadata",
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
],
},
},
exclude: [/node_modules/, path.join(cwd, 'renderer')],
},
],
},
}),
};
this doesn't work anymore
I'm trying to use Nextron to create an Electron app, where I import TypeORM files into
background.ts
, which is the main process file for Electron. TypeORM uses TypeScript decorators, which are experimental.When importing TypeORM files into
/api
pages, the decorators compile fine, since I have the following as my.babelrc
file:However, when I import TypeORM files in the
background.ts
main process file, I get the following error:Clearly, the
@
in this error refers to the@Entity
decorator.How can I make Electron (via Nextron), be able to parse TypeScript decorators?