fix: oxc-parser wasm issue (#484)
This commit is contained in:
parent
f51a8da08d
commit
798aa0ec24
|
|
@ -50,6 +50,7 @@
|
||||||
"@iconify-json/simple-icons": "^1.1.94",
|
"@iconify-json/simple-icons": "^1.1.94",
|
||||||
"@iconify-json/tabler": "^1.1.106",
|
"@iconify-json/tabler": "^1.1.106",
|
||||||
"@iconify/vue": "^4.1.1",
|
"@iconify/vue": "^4.1.1",
|
||||||
|
"@oxc-parser/wasm": "^0.1.0",
|
||||||
"@shikijs/transformers": "^1.3.0",
|
"@shikijs/transformers": "^1.3.0",
|
||||||
"@types/lodash.template": "^4.5.3",
|
"@types/lodash.template": "^4.5.3",
|
||||||
"@types/node": "^20.12.7",
|
"@types/node": "^20.12.7",
|
||||||
|
|
@ -60,7 +61,6 @@
|
||||||
"@vue/tsconfig": "^0.5.1",
|
"@vue/tsconfig": "^0.5.1",
|
||||||
"autoprefixer": "^10.4.19",
|
"autoprefixer": "^10.4.19",
|
||||||
"lodash.template": "^4.5.0",
|
"lodash.template": "^4.5.0",
|
||||||
"oxc-parser": "^0.8.0",
|
|
||||||
"pathe": "^1.1.2",
|
"pathe": "^1.1.2",
|
||||||
"rimraf": "^5.0.5",
|
"rimraf": "^5.0.5",
|
||||||
"shiki": "^1.3.0",
|
"shiki": "^1.3.0",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { readFile, readdir } from 'node:fs/promises'
|
import { readFile, readdir } from 'node:fs/promises'
|
||||||
import { join, normalize, resolve } from 'pathe'
|
import { join, normalize, resolve } from 'pathe'
|
||||||
import { compileScript, parse } from 'vue/compiler-sfc'
|
import { compileScript, parse } from 'vue/compiler-sfc'
|
||||||
import oxc from 'oxc-parser'
|
import { parseSync } from '@oxc-parser/wasm'
|
||||||
|
|
||||||
import type { Registry } from '../../lib/registry'
|
import type { Registry } from '../../lib/registry'
|
||||||
|
|
||||||
|
|
@ -162,12 +162,12 @@ async function getDependencies(filename: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename.endsWith('.ts')) {
|
if (filename.endsWith('.ts')) {
|
||||||
const ast = oxc.parseSync(code, {
|
const ast = parseSync(code, {
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
sourceFilename: filename,
|
sourceFilename: filename,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sources = JSON.parse(ast.program).body.filter((i: any) => i.type === 'ImportDeclaration').map((i: any) => i.source)
|
const sources = ast.program.body.filter((i: any) => i.type === 'ImportDeclaration').map((i: any) => i.source)
|
||||||
sources.forEach((source: any) => {
|
sources.forEach((source: any) => {
|
||||||
populateDeps(source.value)
|
populateDeps(source.value)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxt/kit": "^3.11.2",
|
"@nuxt/kit": "^3.11.2",
|
||||||
"oxc-parser": "^0.8.0"
|
"@oxc-parser/wasm": "^0.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nuxt/devtools": "latest",
|
"@nuxt/devtools": "latest",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { readFileSync, readdirSync } from 'node:fs'
|
import { readFileSync, readdirSync } from 'node:fs'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { addComponent, createResolver, defineNuxtModule } from '@nuxt/kit'
|
import { addComponent, createResolver, defineNuxtModule } from '@nuxt/kit'
|
||||||
import oxc from 'oxc-parser'
|
import { parseSync } from '@oxc-parser/wasm'
|
||||||
|
|
||||||
// TODO: add test to make sure all registry is being parse correctly
|
// TODO: add test to make sure all registry is being parse correctly
|
||||||
// Module options TypeScript interface definition
|
// Module options TypeScript interface definition
|
||||||
|
|
@ -44,14 +44,12 @@ export default defineNuxtModule<ModuleOptions>({
|
||||||
try {
|
try {
|
||||||
const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, 'index'), { extensions: ['.ts', '.js'] })
|
const filePath = await resolvePath(join(COMPONENT_DIR_PATH, dir, 'index'), { extensions: ['.ts', '.js'] })
|
||||||
const content = readFileSync(filePath, { encoding: 'utf8' })
|
const content = readFileSync(filePath, { encoding: 'utf8' })
|
||||||
const ast = oxc.parseSync(content, {
|
const ast = parseSync(content, {
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
sourceFilename: filePath,
|
sourceFilename: filePath,
|
||||||
})
|
})
|
||||||
const program = JSON.parse(ast.program)
|
|
||||||
|
|
||||||
const exportedKeys: string[] = program.body
|
const exportedKeys: string[] = ast.program.body
|
||||||
// @ts-expect-error parse return any
|
|
||||||
.filter(node => node.type === 'ExportNamedDeclaration')
|
.filter(node => node.type === 'ExportNamedDeclaration')
|
||||||
// @ts-expect-error parse return any
|
// @ts-expect-error parse return any
|
||||||
.flatMap(node => node.specifiers.map(specifier => specifier.exported.name))
|
.flatMap(node => node.specifiers.map(specifier => specifier.exported.name))
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,9 @@ importers:
|
||||||
'@iconify/vue':
|
'@iconify/vue':
|
||||||
specifier: ^4.1.1
|
specifier: ^4.1.1
|
||||||
version: 4.1.1(vue@3.4.21)
|
version: 4.1.1(vue@3.4.21)
|
||||||
|
'@oxc-parser/wasm':
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0
|
||||||
'@shikijs/transformers':
|
'@shikijs/transformers':
|
||||||
specifier: ^1.3.0
|
specifier: ^1.3.0
|
||||||
version: 1.3.0
|
version: 1.3.0
|
||||||
|
|
@ -171,9 +174,6 @@ importers:
|
||||||
lodash.template:
|
lodash.template:
|
||||||
specifier: ^4.5.0
|
specifier: ^4.5.0
|
||||||
version: 4.5.0
|
version: 4.5.0
|
||||||
oxc-parser:
|
|
||||||
specifier: ^0.8.0
|
|
||||||
version: 0.8.0
|
|
||||||
pathe:
|
pathe:
|
||||||
specifier: ^1.1.2
|
specifier: ^1.1.2
|
||||||
version: 1.1.2
|
version: 1.1.2
|
||||||
|
|
@ -310,9 +310,9 @@ importers:
|
||||||
'@nuxt/kit':
|
'@nuxt/kit':
|
||||||
specifier: ^3.11.2
|
specifier: ^3.11.2
|
||||||
version: 3.11.2(rollup@3.29.4)
|
version: 3.11.2(rollup@3.29.4)
|
||||||
oxc-parser:
|
'@oxc-parser/wasm':
|
||||||
specifier: ^0.8.0
|
specifier: ^0.1.0
|
||||||
version: 0.8.0
|
version: 0.1.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@nuxt/devtools':
|
'@nuxt/devtools':
|
||||||
specifier: latest
|
specifier: latest
|
||||||
|
|
@ -3031,61 +3031,8 @@ packages:
|
||||||
- vue-tsc
|
- vue-tsc
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@oxc-parser/binding-darwin-arm64@0.8.0:
|
/@oxc-parser/wasm@0.1.0:
|
||||||
resolution: {integrity: sha512-3Dws5Wzj9efojjqvhS4ZF+Abh0EoiI5ciOE2kdLifMzSg4fnmYAIOktoUnPEo87TNIb4SiFJ5JgPBgEyq42Eow==}
|
resolution: {integrity: sha512-oA7XhTbg9rRBJhIzxCNhJwYmON/9LFAH4GBQxl7HWmGSS6HTrb2t6Peq82nxY0W7knguH52neh9T7zs27FVvsQ==}
|
||||||
cpu: [arm64]
|
|
||||||
os: [darwin]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-darwin-x64@0.8.0:
|
|
||||||
resolution: {integrity: sha512-DAUJ/mfq0Jn2VDYn69bhHTsIWj+aZ/viamexFwaLL7ntkIFmGpzAJZUlWofpY1IRJynKWW+P5AOLYXMllw4qUw==}
|
|
||||||
cpu: [x64]
|
|
||||||
os: [darwin]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-linux-arm64-gnu@0.8.0:
|
|
||||||
resolution: {integrity: sha512-ZHQVey/O4K3zTIKtpfsbtJIE8MPTRHRxgY3dejaoeFQGf9C3HasgF132Yp4zN/jOUx+x8czKPVa/Af40ViyhGQ==}
|
|
||||||
cpu: [arm64]
|
|
||||||
os: [linux]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-linux-arm64-musl@0.8.0:
|
|
||||||
resolution: {integrity: sha512-Diw+Tnf5v+zAYXzDoSKCZsMaroU6GoqZMS7smfDtFnZYTHWZrsTmPBLUQe7AFiG7O7tkhsCdcWjOYgbVkrSVOA==}
|
|
||||||
cpu: [arm64]
|
|
||||||
os: [linux]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-linux-x64-gnu@0.8.0:
|
|
||||||
resolution: {integrity: sha512-WloqcRrtQUVEP/Sy8ZeEgF0HgBKQjOv3zLFZqbC5ipkerKriGcVbsq3fOIMOi/55AM6/UhIAjeZGnoeco72JjQ==}
|
|
||||||
cpu: [x64]
|
|
||||||
os: [linux]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-linux-x64-musl@0.8.0:
|
|
||||||
resolution: {integrity: sha512-2j7BD9szwSXTvSj0Q8VE98UHGYvrgZzdLy4EyB0FilhQnopEfz+YV674rWGY2Il1VYxHJwGctrTJHvARolu37g==}
|
|
||||||
cpu: [x64]
|
|
||||||
os: [linux]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-win32-arm64-msvc@0.8.0:
|
|
||||||
resolution: {integrity: sha512-mcomr1og17yCmnwn8Q7CRzrH9Va0HccWe4Ld3/u/elBsw0SEzYGVvECRzCyRglYAbKTtusz7as9Jee0RiMOMmg==}
|
|
||||||
cpu: [arm64]
|
|
||||||
os: [win32]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@oxc-parser/binding-win32-x64-msvc@0.8.0:
|
|
||||||
resolution: {integrity: sha512-nIBkc1KZOVYUaHT3+U+gM354P3byMAIXMvlmLMbs0kWVRcI4vrzL8qwWpC6QdBQxWKZGqPEqGolv8H4dDYA9nQ==}
|
|
||||||
cpu: [x64]
|
|
||||||
os: [win32]
|
|
||||||
requiresBuild: true
|
|
||||||
optional: true
|
|
||||||
|
|
||||||
/@parcel/watcher-android-arm64@2.4.1:
|
/@parcel/watcher-android-arm64@2.4.1:
|
||||||
resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==}
|
resolution: {integrity: sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==}
|
||||||
|
|
@ -11405,18 +11352,6 @@ packages:
|
||||||
os-tmpdir: 1.0.2
|
os-tmpdir: 1.0.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/oxc-parser@0.8.0:
|
|
||||||
resolution: {integrity: sha512-ObPeMkbDX7igb7NyyAC8CbVC3fY+YmlMsxsRQ2oyFBkpQtI5tjoyqSDKbS9A9EcJvt2q89C4UoC+HjVBdLYYJg==}
|
|
||||||
optionalDependencies:
|
|
||||||
'@oxc-parser/binding-darwin-arm64': 0.8.0
|
|
||||||
'@oxc-parser/binding-darwin-x64': 0.8.0
|
|
||||||
'@oxc-parser/binding-linux-arm64-gnu': 0.8.0
|
|
||||||
'@oxc-parser/binding-linux-arm64-musl': 0.8.0
|
|
||||||
'@oxc-parser/binding-linux-x64-gnu': 0.8.0
|
|
||||||
'@oxc-parser/binding-linux-x64-musl': 0.8.0
|
|
||||||
'@oxc-parser/binding-win32-arm64-msvc': 0.8.0
|
|
||||||
'@oxc-parser/binding-win32-x64-msvc': 0.8.0
|
|
||||||
|
|
||||||
/p-finally@1.0.0:
|
/p-finally@1.0.0:
|
||||||
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
|
resolution: {integrity: sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user