@@ -74,41 +74,6 @@ function readDeclarationName(node) {
7474 return null ;
7575}
7676
77- function unwrapExpression ( node ) {
78- let current = node ;
79- while (
80- ts . isParenthesizedExpression ( current ) ||
81- ts . isAsExpression ( current ) ||
82- ts . isTypeAssertionExpression ( current ) ||
83- ts . isSatisfiesExpression ( current )
84- ) {
85- current = current . expression ;
86- }
87- return current ;
88- }
89-
90- function isCanonicalLazyLoaderExpression ( node ) {
91- const expression = unwrapExpression ( node ) ;
92- return (
93- ts . isCallExpression ( expression ) &&
94- ts . isIdentifier ( expression . expression ) &&
95- expression . expression . text . startsWith ( "createLazy" )
96- ) ;
97- }
98-
99- function containsDynamicImport ( node ) {
100- let found = false ;
101- const visit = ( current ) => {
102- if ( ts . isCallExpression ( current ) && current . expression . kind === ts . SyntaxKind . ImportKeyword ) {
103- found = true ;
104- return ;
105- }
106- ts . forEachChild ( current , visit ) ;
107- } ;
108- visit ( node ) ;
109- return found ;
110- }
111-
11277function isIgnoredTestHelperContent ( content ) {
11378 return / \b f r o m \s + [ " ' ] v i t e s t [ " ' ] / . test ( content ) || / \b f r o m \s + [ " ' ] @ v i t e s t \/ / . test ( content ) ;
11479}
@@ -134,7 +99,6 @@ export function findDynamicImportAdvisories(content, fileName = "source.ts") {
13499 const staticRuntimeImports = new Map ( ) ;
135100 const dynamicImports = new Map ( ) ;
136101 const directExecuteImports = [ ] ;
137- const manualMemoizers = [ ] ;
138102 const declarationStack = [ ] ;
139103
140104 const addLine = ( map , specifier , line ) => {
@@ -184,19 +148,6 @@ export function findDynamicImportAdvisories(content, fileName = "source.ts") {
184148 }
185149 }
186150
187- if (
188- ts . isBinaryExpression ( node ) &&
189- node . operatorToken . kind === ts . SyntaxKind . QuestionQuestionEqualsToken &&
190- containsDynamicImport ( node . right ) &&
191- ! isCanonicalLazyLoaderExpression ( node . right )
192- ) {
193- manualMemoizers . push ( {
194- line : toLine ( sourceFile , node ) ,
195- reason :
196- "hand-written dynamic import memoizer; use createLazyPromise or createLazyRuntimeModule" ,
197- } ) ;
198- }
199-
200151 ts . forEachChild ( node , visit ) ;
201152 if ( declarationName ) {
202153 declarationStack . pop ( ) ;
@@ -205,7 +156,7 @@ export function findDynamicImportAdvisories(content, fileName = "source.ts") {
205156
206157 visit ( sourceFile ) ;
207158
208- const advisories = [ ...directExecuteImports , ... manualMemoizers ] ;
159+ const advisories = [ ...directExecuteImports ] ;
209160 for ( const [ specifier , dynamicLines ] of dynamicImports ) {
210161 const staticLines = staticRuntimeImports . get ( specifier ) ;
211162 if ( staticLines ?. length ) {
@@ -256,7 +207,6 @@ export async function collectDynamicImportAdvisories(options = {}) {
256207 */
257208export async function main ( argv = process . argv . slice ( 2 ) ) {
258209 const fail = argv . includes ( "--fail" ) ;
259- const failManualMemoizers = argv . includes ( "--fail-manual-memoizers" ) ;
260210 const json = argv . includes ( "--json" ) ;
261211 const advisories = await collectDynamicImportAdvisories ( ) ;
262212
@@ -275,14 +225,6 @@ export async function main(argv = process.argv.slice(2)) {
275225 if ( fail && advisories . length > 0 ) {
276226 process . exit ( 1 ) ;
277227 }
278- if (
279- failManualMemoizers &&
280- advisories . some ( ( advisory ) =>
281- advisory . reason . startsWith ( "hand-written dynamic import memoizer" ) ,
282- )
283- ) {
284- process . exit ( 1 ) ;
285- }
286228}
287229
288230runAsScript ( import . meta. url , main ) ;
0 commit comments