Currently imports are converted to dynamic imports, for example:
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import { unified } from 'unified'
export const remark = unified()
.use(remarkParse)
.use(remarkStringify)
becomes:
'use strict'
const [
{ default: remarkParse },
{ default: remarkStringify },
{ unified }
] = await Promise.all([
import('remark-parse'),
import('remark-stringify'),
import('unified')
])
const remark = unified()
.use(remarkParse)
.use(remarkStringify)
return {
remark
}
To evaluate this requires the AsyncFunction constructor, which isn’t globally available.
Instead, it could be transformed into:
return Promise.all([
import('remark-parse'),
import('remark-stringify'),
import('unified')
]).then(async ([
{ default: remarkParse },
{ default: remarkStringify },
{ unified }
]) => {
'use strict'
const remark = unified()
.use(remarkParse)
.use(remarkStringify)
return {
remark
}
})
This means the result can be evaluated with the globally available Function constructor.
Currently imports are converted to dynamic imports, for example:
becomes:
To evaluate this requires the
AsyncFunctionconstructor, which isn’t globally available.Instead, it could be transformed into:
This means the result can be evaluated with the globally available
Functionconstructor.