-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autoInjectable not working in Chrome Extension using Webpack #142
Comments
Can you share your config files (`webpack.*.config, tsconfig.json, .babelrc, etc.)? |
Hello @MeltingMosaic I am not using babel but here are the other requested files :) // webpack.common.js
const path = require('path');
const src = '../src/';
const assets = '../assets'
const dist = '../dist/'
module.exports = {
entry: {
background: path.join(__dirname, src + '/background/background.ts')
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /(node_modules|test)/,
},
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
output: {
path: path.join(__dirname, dist + '/js'),
filename: '[name].js'
},
}; // webpack.prod.js
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
module.exports = merge(common, {
mode: 'production'
}); // tsconfig.json
{
"compilerOptions": {
"outDir": "./dist/",
"module": "commonjs",
"target": "ES6",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true
} |
same issue |
Interesting. Do you have a repo I could fork? I've never written a chrome extension before, so I don't quite know how to set this up for repro. |
Sure, I'll setup a minimal example repo tomorrow and link it here. |
Here is your requested repo :) Just follow the install instructions in the Readme. |
Thanks. I'll try to find some time to investigate it. |
@Xapphire13 if you get a chance, could you take a look at this? I can repro it, but I don't understand what's going on. |
It looks like webpack is prefering the
|
Thanks @ffortier . Your solution solves my problem. |
Not to resurrect this, but is there any way that this could be solved by the repository rather than by each user? Same issue today when running webpack but packing files for a Node runtime and using |
I was unable to resolve this issue in Bun environment. There are no aliases and the only option is |
Describe the bug
TSyringe seems not to be working when used in a Chrome Extension using Webpack and ts-loader.
To Reproduce
Expected behavior
Expected
new ConfigService()
to return a ConfigService instance with dependencies resolved automatically.Actual behavior
new ConfigService()
throws an uncaught TypeError Class constructor ConfigService cannot be invoked without 'new'Version: 4.4.0
The text was updated successfully, but these errors were encountered: