File tree Expand file tree Collapse file tree 5 files changed +12
-6
lines changed
Expand file tree Collapse file tree 5 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1- import type { StateContext } from './types' ;
21import * as t from '@babel/types' ;
2+ import type { StateContext } from './types' ;
33
44export function getHotIdentifier ( state : StateContext ) : t . MemberExpression {
55 switch ( state . bundler ) {
Original file line number Diff line number Diff line change 1+ import type * as babel from '@babel/core' ;
2+ import * as t from '@babel/types' ;
13import type {
24 ImportIdentifierSpecifier ,
35 ImportIdentifierType ,
46 StateContext ,
57} from './types' ;
68import { unwrapNode } from './unwrap' ;
7- import type * as babel from '@babel/core' ;
8- import * as t from '@babel/types' ;
99
1010function isIdentifierValidCallee (
1111 state : StateContext ,
Original file line number Diff line number Diff line change @@ -188,6 +188,8 @@ function convertJSXOpeningToExpression(
188188 ) ;
189189}
190190
191+ const COMPONENT_PATTERN = / ^ [ A - Z _ ] / ;
192+
191193function extractJSXExpressionsFromJSXElement (
192194 state : JSXState ,
193195 path : babel . NodePath < t . JSXElement > ,
@@ -196,7 +198,7 @@ function extractJSXExpressionsFromJSXElement(
196198 const openingName = openingElement . get ( 'name' ) ;
197199 if (
198200 ( isPathValid ( openingName , t . isJSXIdentifier ) &&
199- / ^ [ A - Z _ ] / . test ( openingName . node . name ) ) ||
201+ COMPONENT_PATTERN . test ( openingName . node . name ) ) ||
200202 isPathValid ( openingName , t . isJSXMemberExpression )
201203 ) {
202204 if ( isPathValid ( openingName , t . isJSXIdentifier ) ) {
Original file line number Diff line number Diff line change 1+ // @ts -nocheck
12/**
23 * Copyright (c) 2019 Jason Dent
34 * https://github.com/Jason3S/xxhash
Original file line number Diff line number Diff line change @@ -176,6 +176,9 @@ function wrapContext(
176176 return context ;
177177}
178178
179+ const SKIP_PATTERN = / ^ \s * @ r e f r e s h s k i p \s * $ / ;
180+ const RELOAD_PATTERN = / ^ \s * @ r e f r e s h r e l o a d \s * $ / ;
181+
179182function setupProgram (
180183 state : StateContext ,
181184 path : babel . NodePath < t . Program > ,
@@ -185,12 +188,12 @@ function setupProgram(
185188 let isDone = false ;
186189 if ( comments ) {
187190 for ( const { value : comment } of comments ) {
188- if ( / ^ \s * @ r e f r e s h s k i p \s * $ / . test ( comment ) ) {
191+ if ( SKIP_PATTERN . test ( comment ) ) {
189192 isDone = true ;
190193 shouldSkip = true ;
191194 break ;
192195 }
193- if ( / ^ \s * @ r e f r e s h r e l o a d \s * $ / . test ( comment ) ) {
196+ if ( RELOAD_PATTERN . test ( comment ) ) {
194197 isDone = true ;
195198 path . pushContainer ( 'body' , getHMRDeclineCall ( state , path ) ) ;
196199 break ;
You can’t perform that action at this time.
0 commit comments