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

chore(infra/biome): enable noGlobalEval #7623

Merged

Conversation

shulaoda
Copy link
Collaborator

Summary

Related to #7182

I don't know if this is the right thing to do. Why use eval? Is there any special situation?

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Aug 20, 2024

Deploy Preview for rspack canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit 6500a39
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/66c4519dd7f8990008b164db

@shulaoda
Copy link
Collaborator Author

@SoonIter cc

@SoonIter
Copy link
Member

const dynamicImport = (specifier) => eval(import(${specifier}))
or const dynamicImport = new Function('specifier', 'return import(specifier)');`

https://github.com/TypeStrong/ts-node/blob/ddb05ef23be92a90c3ecac5a0220435c65ebbd2a/src/test/resolver.spec.ts#L76-L81

it is a trick to avoid tsc transform the dynamic import

@SoonIter
Copy link
Member

it is a trick to avoid tsc transform the dynamic import

Sorry, this code is moved from the webpack and should be used to be compatible with node8.

this trick can be used in two cases:

  1. avoid import from being transformed by tsc toPromise.resolve().then(() => require('foo'))
  2. node8

@SoonIter
Copy link
Member

image You can check the dist. If the import in dist is not transformed by tsc, it can be merged.

@shulaoda
Copy link
Collaborator Author

@SoonIter same

@SoonIter SoonIter merged commit c7f86b5 into web-infra-dev:main Aug 20, 2024
33 checks passed
@SoonIter
Copy link
Member

LGTM :D

@shulaoda shulaoda deleted the chore/biome-enable-noGlobalEval branch August 20, 2024 09:37
@chenjiahan chenjiahan mentioned this pull request Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants