fix(scripts): remove side effect then chain support for as-require plugin
This commit is contained in:
parent
f9322b7bc6
commit
280ebdc731
1 changed files with 0 additions and 12 deletions
|
|
@ -6,7 +6,6 @@ import type { RolldownPlugin } from 'rolldown'
|
|||
* Supported statements:
|
||||
* - Static side-effect imports: `import 'module'`
|
||||
* - Dynamic side-effect imports: `import('module')` and `await import('module')`
|
||||
* - Dynamic imports with .then(): `import('module').then(mod => ...)`
|
||||
*/
|
||||
export default function asRequire() {
|
||||
return {
|
||||
|
|
@ -21,17 +20,6 @@ export default function asRequire() {
|
|||
const newCode = code.replace(asRequireRegex, (match, statement) => {
|
||||
const trimmedStatement = statement.trim()
|
||||
|
||||
// import('./mod').then(mod => mod.do()) -> ((mod => mod.do()))(require('./mod'))
|
||||
const importThenRegex =
|
||||
/^import\((['"])(.+?)\1\)\s*\.then\(([\s\S]+)\);?$/
|
||||
const thenMatch = trimmedStatement.match(importThenRegex)
|
||||
if (thenMatch) {
|
||||
hasChanged = true
|
||||
const modulePath = `${thenMatch[1]}${thenMatch[2]}${thenMatch[1]}`
|
||||
const callback = thenMatch[3].trim()
|
||||
return `\n((${callback}))(require(${modulePath}));`
|
||||
}
|
||||
|
||||
// import './mod' -> require('./mod')
|
||||
const staticSideEffectRegex = /^import\s+(['"])(.+?)\1;?$/
|
||||
const staticMatch = trimmedStatement.match(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue