#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?<=^|[\n;](?:[\t ]*(?:\w+ )?)?)import\s*(?<type>type(?=\s+))?(?:[\s"']*(?<imports>[\w\t\n\r "$'*,/{}-]+?)\s+from\s*)?["']\s*(?<specifier>(?:(?<='\s*)[^']*[^\s'](?=\s*'))|(?:(?<="\s*)[^"]*[^\s"](?=\s*")))\s*["'](?:\s+assert\s+(?<assertion>{[\w\t\n\r "':]+?}))?(?=[\s;]*)"
Local $sString = "/**" & @CRLF & _
" * @file Interfaces" & @CRLF & _
" * @module mlly/interfaces" & @CRLF & _
" */" & @CRLF & _
"" & @CRLF & _
"export type { default as DynamicImport } from './import-dynamic'" & @CRLF & _
"export type { default as StaticImport } from './import-static'" & @CRLF & _
"export type { default as ResolveOptions } from './options-resolve'" & @CRLF & _
"export type { default as ResolveAliasOptions } from './options-resolve-alias'" & @CRLF & _
"export type { default as Statement } from './statement'" & @CRLF & _
"export type { default as ExportStatement } from './statement-export'" & @CRLF & _
"export type { default as ImportStatement } from './statement-import'" & @CRLF & _
"export type { default as RequireStatement } from './statement-require'" & @CRLF & _
"" & @CRLF & _
"import { CONDITIONS, RESOLVE_EXTENSIONS } from '#src/constants'" & @CRLF & _
"import type { ResolveOptions } from '#src/interfaces'" & @CRLF & _
"import type { SpecifierType } from '#src/types'" & @CRLF & _
"import isBuiltin from '@flex-development/is-builtin'" & @CRLF & _
"import { moduleResolve, type ErrnoException } from 'import-meta-resolve'" & @CRLF & _
"import { pathToFileURL, URL } from 'node:url'" & @CRLF & _
"import upath from 'upath'" & @CRLF & _
"import toBareSpecifier from './to-bare-specifier'" & @CRLF & _
"import toRelativeSpecifier from './to-relative-specifier'" & @CRLF & _
"import 'file:///home/dir/file.ts'" & @CRLF & _
"" & @CRLF & _
"import pkg from './package.json' assert { type:'json' }" & @CRLF & _
"import * as color from 'colorette'" & @CRLF & _
"import consola from 'consola'" & @CRLF & _
"import { defu } from 'defu'" & @CRLF & _
"import type { Format } from 'esbuild'" & @CRLF & _
"import fse from 'fs-extra'" & @CRLF & _
"import * as pathe from 'pathe'" & @CRLF & _
"import { resolve } from 'node:path'" & @CRLF & _
"import url from 'node:url'" & @CRLF & _
"import type { PackageJson } from 'pkg-types'" & @CRLF & _
"import pb from 'pretty-bytes'" & @CRLF & _
"import { EXT_DTS_REGEX, IGNORE_PATTERNS } from './config/constants'" & @CRLF & _
"import loadBuildConfig from './config/load'" & @CRLF & _
"import type { Config, Entry, Result } from './interfaces'" & @CRLF & _
"import type { OutputExtension } from './types'" & @CRLF & _
"import { readPackage, type PackageJson } from "read-pkg"" & @CRLF & _
"import {OutputExtension} from './types'" & @CRLF & _
"import analyzeResults from './utils/analyze-results'" & @CRLF & _
"import esbuilder from './utils/esbuilder'; import write from './utils/write';import write2 from './utils/write'" & @CRLF & _
"// import write from './utils/write'" & @CRLF & _
"import 'side-effect.mjs'" & @CRLF & _
"import type StatementType from '../types/statement-type'" & @CRLF & _
"import type {" & @CRLF & _
" BuildOptions," & @CRLF & _
" BuildResult," & @CRLF & _
" OutputFile," & @CRLF & _
" Plugin," & @CRLF & _
" PluginBuild" & @CRLF & _
"} from './esbuild'" & @CRLF & _
"" & @CRLF & _
"import defaultExport from "module-name";" & @CRLF & _
"import * as name from "module-name";" & @CRLF & _
"import { export1 } from "module-name";" & @CRLF & _
"import { export1 as alias1 } from "module-name";" & @CRLF & _
"import { default as alias } from "module-name";" & @CRLF & _
"import { export1, export2 } from "module-name";" & @CRLF & _
"import { export1, export2 as alias2 } from "module-name";" & @CRLF & _
"import { 'string name' as alias } from "module-name";" & @CRLF & _
"import { "string name" as alias } from "module-name";" & @CRLF & _
"import defaultExport, { export1 } from "module-name";" & @CRLF & _
"import defaultExport, * as name from "module-name";" & @CRLF & _
"import "module-name";" & @CRLF & _
"import 'module-name';" & @CRLF & _
"import './polyfill.mjs'" & @CRLF & _
"import { "h-i" as hi } from './hi.js'" & @CRLF & _
"import { 'j-k' as jk } from "./jk.js"" & @CRLF & _
"" & @CRLF & _
"declare module '__fixtures__/values' {" & @CRLF & _
" import MAX_VALUE from '#fixtures/max-value'" & @CRLF & _
" import MIN_VALUE from '#fixtures/min-value'" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"const ERR_UNSUPPORTED_DIR_IMPORT: NodeErrorConstructor<" & @CRLF & _
" ErrorConstructor," & @CRLF & _
" [string, string]" & @CRLF & _
"> = createNodeError(" & @CRLF & _
" ErrorCode.ERR_UNSUPPORTED_DIR_IMPORT," & @CRLF & _
" Error," & @CRLF & _
" 'Directory import '%s' is not supported resolving ES modules imported from %s'" & @CRLF & _
")" & @CRLF & _
"" & @CRLF & _
"const text: string = await resolveModules(output.text, {" & @CRLF & _
" conditions: [format === 'esm' ? 'import' : 'require']," & @CRLF & _
" ext: ext as Ext," & @CRLF & _
" extensions," & @CRLF & _
" parent" & @CRLF & _
"})" & @CRLF & _
"" & @CRLF & _
"/**" & @CRLF & _
" * @example" & @CRLF & _
" * import write from './utils/write'" & @CRLF & _
" * write()" & @CRLF & _
" */" & @CRLF & _
"" & @CRLF & _
"import { 'j-k' as jk } from "./jk.js""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm