Cannot use webpack's resolve.alias
Cannot use webpack's resolve.alias
resolve: { '@': resolve('source') }
Error: failed to parse config file: data did not match any variant of untagged enum Rc @ multi
Can you share your config code related to swc-loader?
webpack config:
{
test: /\.[t|j]sx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'swc-loader',
include: [resolve('src'), resolve('source'), resolve('test')],
}
.swcrc:
{
"jsc": {
"transform": {
"react": {
"pragma": "React.createElement",
"pragmaFrag": "React.Fragment",
"throwIfNamespace": true,
"development": false,
"useBuiltins": false
}
},
"parser": {
"syntax": "ecmascript",
"jsx": true,
"classProperty": true,
"decorators": true,
"optionalChaining": true
}
}
}
@xxoojs Can you share your config file related to resolve?
I'm trying to reproduce it, but I don't know where I should put "@": path.resolve("source").
@kdy1 maybe this?
{
test: /\.[t|j]sx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'swc-loader',
include: [resolve('src'), resolve('source'), resolve('test')],
resolve: {
alias: {
"@": path.resolve("source")
}
}
}
@Austaras I'll try to fix it.
resolve is a top-level key in Webpack; the config above should be something like:
module.exports = {
module: {
rules: [
{
test: /\.[t|j]sx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'swc-loader',
}
],
},
resolve: {
alias: {
"@": path.resolve("whatever"),
},
},
};
FWIW, it works locally when putting resolve at the correct level.
Is this issue still open for contributors?
Yes
Yes
Great. I want to contribute here, but this would be my first contribution.
I read over the CONTRIBUTING.md file but I'm not familiar with the codebase. Which files would need to be changed? Could you help, or guide me to where I can find the information? Thank you.
I don't know where to start. https://rustdoc.swc.rs/swc/ may help
When I use vanilla JavaScript this seems to work, Maybe this was fixed or this is only an issue on with React
@kdy1 Is there any progress on this issue?
Is there any update or work around for this? Experiencing this issue currently.
We are open to accept contributions / PRs, otherwise unless issue explicitly updates there are no updates.
If it is of value to anyone else trying to trouble shoot this. I have a reproduction repo.
https://github.com/swalker326/rspack-module-federation
I only saw the error once I installed @module-federation/utilities I'm kinda lost in where it is actually coming from but trying my best, lol.
If it is of value to anyone else trying to trouble shoot this. I have a reproduction repo.
https://github.com/swalker326/rspack-module-federation
I only saw the error once I installed
@module-federation/utilitiesI'm kinda lost in where it is actually coming from but trying my best, lol.
This is unrelated to swc, let's move the issue to https://github.com/web-infra-dev/rspack
https://github.com/swc-project/swc/issues/8486 working for me