mirror of
https://github.com/swc-project/swc.git
synced 2024-11-21 21:41:48 +03:00
fix(es/resolver): Skip resolving lowercase JSXIdentifiers
(#9686)
Some checks are pending
CI / Cargo fmt (push) Waiting to run
CI / Cargo clippy (push) Waiting to run
CI / Check license of dependencies (push) Waiting to run
CI / Check (macos-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / Test wasm (binding_core_wasm) (push) Waiting to run
CI / Test wasm (binding_minifier_wasm) (push) Waiting to run
CI / Test wasm (binding_typescript_wasm) (push) Waiting to run
CI / List crates (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Blocked by required conditions
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Waiting to run
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Waiting to run
CI / Test with @swc/cli (push) Waiting to run
CI / Miri (better_scoped_tls) (push) Waiting to run
CI / Miri (string_enum) (push) Waiting to run
CI / Miri (swc) (push) Waiting to run
CI / Miri (swc_bundler) (push) Waiting to run
CI / Done (push) Blocked by required conditions
Benchmark / Bench everything (push) Waiting to run
Publish crates (auto) / Publish cargo crates (push) Waiting to run
Some checks are pending
CI / Cargo fmt (push) Waiting to run
CI / Cargo clippy (push) Waiting to run
CI / Check license of dependencies (push) Waiting to run
CI / Check (macos-latest) (push) Waiting to run
CI / Check (ubuntu-latest) (push) Waiting to run
CI / Check (windows-latest) (push) Waiting to run
CI / Test wasm (binding_core_wasm) (push) Waiting to run
CI / Test wasm (binding_minifier_wasm) (push) Waiting to run
CI / Test wasm (binding_typescript_wasm) (push) Waiting to run
CI / List crates (push) Waiting to run
CI / Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} (push) Blocked by required conditions
CI / Test node bindings - ${{ matrix.os }} (macos-latest) (push) Waiting to run
CI / Test node bindings - ${{ matrix.os }} (windows-latest) (push) Waiting to run
CI / Test with @swc/cli (push) Waiting to run
CI / Miri (better_scoped_tls) (push) Waiting to run
CI / Miri (string_enum) (push) Waiting to run
CI / Miri (swc) (push) Waiting to run
CI / Miri (swc_bundler) (push) Waiting to run
CI / Done (push) Blocked by required conditions
Benchmark / Bench everything (push) Waiting to run
Publish crates (auto) / Publish cargo crates (push) Waiting to run
**Related issue:** - Closes https://github.com/swc-project/swc/issues/9685
This commit is contained in:
parent
4b4dcfa4d8
commit
6ed1715b93
6
.changeset/fluffy-eyes-hope.md
Normal file
6
.changeset/fluffy-eyes-hope.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
swc_ecma_transforms_base: patch
|
||||
swc_core: patch
|
||||
---
|
||||
|
||||
fix(es/resolver): Skip resolving lowercase JSXIdentifiers
|
@ -0,0 +1,4 @@
|
||||
export namespace form {
|
||||
export const input = null;
|
||||
export const test = <input />
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
(function(form) {
|
||||
form.input = null;
|
||||
form.test = /*#__PURE__*/ React.createElement("input", null);
|
||||
})(form || (form = {}));
|
||||
export var form;
|
@ -920,6 +920,28 @@ impl VisitMut for Resolver<'_> {
|
||||
f.body.visit_mut_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_jsx_element_name(&mut self, node: &mut JSXElementName) {
|
||||
if let JSXElementName::Ident(i) = node {
|
||||
if i.as_ref().starts_with(|c: char| c.is_ascii_lowercase()) {
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
debug!("\t -> JSXElementName");
|
||||
}
|
||||
|
||||
let ctxt = i.ctxt.apply_mark(self.config.unresolved_mark);
|
||||
|
||||
if cfg!(debug_assertions) && LOG {
|
||||
debug!("\t -> {:?}", ctxt);
|
||||
}
|
||||
|
||||
i.ctxt = ctxt;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
node.visit_mut_children_with(self);
|
||||
}
|
||||
|
||||
fn visit_mut_ident(&mut self, i: &mut Ident) {
|
||||
if i.ctxt != SyntaxContext::empty() {
|
||||
return;
|
||||
|
@ -84,10 +84,12 @@ fn test_resolver(input: PathBuf) {
|
||||
}
|
||||
|
||||
#[fixture("tests/ts-resolver/**/input.ts")]
|
||||
#[fixture("tests/ts-resolver/**/input.tsx")]
|
||||
fn test_ts_resolver(input: PathBuf) {
|
||||
run(
|
||||
Syntax::Typescript(TsSyntax {
|
||||
decorators: true,
|
||||
tsx: input.extension().filter(|ext| *ext == "tsx").is_some(),
|
||||
..Default::default()
|
||||
}),
|
||||
&input,
|
||||
|
@ -0,0 +1,4 @@
|
||||
export namespace form {
|
||||
export const input = null;
|
||||
export const test = <input />;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export namespace form__2 {
|
||||
export const input__3 = null;
|
||||
export const test__3 = <input/>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user