Skip to content
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

[Bug] Invalid fallback "javascript/auto" rule.type passed to getRawGeneratorOptions #6873

Closed
omonk opened this issue Jun 20, 2024 · 4 comments

Comments

@omonk
Copy link

omonk commented Jun 20, 2024

? getRawGeneratorOptions(rule.generator, rule.type ?? "javascript/auto")

The default type argument is "javascript/auto" which throws an error during build as there is no condition which matches

Error: unreachable: unknow module type: javascript/auto

function getRawGeneratorOptions(
generator: { [k: string]: any },
type: string
): RawGeneratorOptions {
if (type === "asset") {
return {
type: "asset",
asset: generator ? getRawAssetGeneratorOptions(generator) : undefined
};
}
if (type === "asset/inline") {
return {
type: "asset/inline",
assetInline: generator
? getRawAssetInlineGeneratorOptions(generator)
: undefined
};
}
if (type === "asset/resource") {
return {
type: "asset/resource",
assetResource: generator
? getRawAssetResourceGeneratorOptions(generator)
: undefined
};
}
if (type === "css") {
return {
type: "css",
css: getRawCssGeneratorOptions(generator)
};
}
if (type === "css/auto") {
return {
type: "css/auto",
cssAuto: getRawCssAutoOrModuleGeneratorOptions(generator)
};
}
if (type === "css/module") {
return {
type: "css/module",
cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
};
}
throw new Error(`unreachable: unknow module type: ${type}`);
}

@omonk omonk changed the title Invalid fallback "javascript/auto" rule.type passed to getRawGeneratorOptions [Bug] Invalid fallback "javascript/auto" rule.type passed to getRawGeneratorOptions Jun 20, 2024
@xc2
Copy link
Collaborator

xc2 commented Jun 20, 2024

Are you passing an empty generator config to a rule item?

@xc2 xc2 added pending triage The issue/PR is currently untouched. labels Jun 20, 2024
@xc2 xc2 added awaiting more feedback and removed pending triage The issue/PR is currently untouched. labels Jun 29, 2024
@ahabhgk
Copy link
Collaborator

ahabhgk commented Jul 3, 2024

@ahabhgk ahabhgk closed this as completed Jul 3, 2024
@ahabhgk
Copy link
Collaborator

ahabhgk commented Jul 3, 2024

Feel free to re-open if it still exists in v1.0.0-alpha.1

@9aoy
Copy link
Collaborator

9aoy commented Jul 15, 2024

It seems that it just avoids using javascript/auto as the default value. When I manually set the type to javascript/auto in rspack v1.0.0-alpha.3, I still encounter this error.

image

According to the introduction of webpack, when the type is javascript/auto, it seems that it should be ignored instead of throw an error. see

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants