penambahan web socket
This commit is contained in:
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024-present VoidZero Inc. & Contributors
|
||||
Copyright (c) 2023 Boshen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
# Oxc Minify
|
||||
|
||||
This is alpha software and may yield incorrect results, feel free to [submit a bug report](https://github.com/oxc-project/oxc/issues/new?assignees=&labels=C-bug&projects=&template=bug_report.md).
|
||||
|
||||
### Performance and Compression Size
|
||||
|
||||
See [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks) for details.
|
||||
|
||||
The current version already outperforms `esbuild`,
|
||||
but it still lacks a few key minification techniques
|
||||
such as constant inlining and dead code removal,
|
||||
which we plan to implement next.
|
||||
|
||||
## Caveats
|
||||
|
||||
To maximize performance, `oxc-minify` assumes the input code is semantically correct.
|
||||
It uses `oxc-parser`'s fast mode to parse the input code,
|
||||
which does not check for semantic errors related to symbols and scopes.
|
||||
|
||||
## API
|
||||
|
||||
```javascript
|
||||
import { minify } from 'oxc-minify';
|
||||
|
||||
const filename = 'test.js';
|
||||
const code = "const x = 'a' + 'b'; console.log(x);";
|
||||
const options = {
|
||||
compress: {
|
||||
target: 'esnext',
|
||||
},
|
||||
mangle: {
|
||||
toplevel: false,
|
||||
},
|
||||
codegen: {
|
||||
removeWhitespace: true,
|
||||
},
|
||||
sourcemap: true,
|
||||
};
|
||||
const result = minify(filename, code, options);
|
||||
|
||||
console.log(result.code);
|
||||
console.log(result.map);
|
||||
```
|
||||
|
||||
## Assumptions
|
||||
|
||||
`oxc-minify` makes some assumptions about the source code.
|
||||
|
||||
See https://github.com/oxc-project/oxc/blob/main/crates/oxc_minifier/README.md#assumptions for details.
|
||||
|
||||
### Supports WASM
|
||||
|
||||
See https://stackblitz.com/edit/oxc-minify for usage example.
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from '@oxc-minify/binding-wasm32-wasi'
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/* auto-generated by NAPI-RS */
|
||||
/* eslint-disable */
|
||||
export interface CodegenOptions {
|
||||
/**
|
||||
* Remove whitespace.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
removeWhitespace?: boolean
|
||||
}
|
||||
|
||||
export interface CompressOptions {
|
||||
/**
|
||||
* Set desired EcmaScript standard version for output.
|
||||
*
|
||||
* Set `esnext` to enable all target highering.
|
||||
*
|
||||
* e.g.
|
||||
*
|
||||
* * catch optional binding when >= es2019
|
||||
* * `??` operator >= es2020
|
||||
*
|
||||
* @default 'esnext'
|
||||
*/
|
||||
target?: 'esnext' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024'
|
||||
/**
|
||||
* Pass true to discard calls to `console.*`.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
dropConsole?: boolean
|
||||
/**
|
||||
* Remove `debugger;` statements.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
dropDebugger?: boolean
|
||||
/**
|
||||
* Drop unreferenced functions and variables.
|
||||
*
|
||||
* Simple direct variable assignments do not count as references unless set to "keep_assign".
|
||||
*/
|
||||
unused?: true | false | 'keep_assign'
|
||||
/** Keep function / class names. */
|
||||
keepNames?: CompressOptionsKeepNames
|
||||
}
|
||||
|
||||
export interface CompressOptionsKeepNames {
|
||||
/**
|
||||
* Keep function names so that `Function.prototype.name` is preserved.
|
||||
*
|
||||
* This does not guarantee that the `undefined` name is preserved.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
function: boolean
|
||||
/**
|
||||
* Keep class names so that `Class.prototype.name` is preserved.
|
||||
*
|
||||
* This does not guarantee that the `undefined` name is preserved.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
class: boolean
|
||||
}
|
||||
|
||||
export interface MangleOptions {
|
||||
/**
|
||||
* Pass `true` to mangle names declared in the top level scope.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
toplevel?: boolean
|
||||
/**
|
||||
* Preserve `name` property for functions and classes.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
keepNames?: boolean | MangleOptionsKeepNames
|
||||
/** Debug mangled names. */
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export interface MangleOptionsKeepNames {
|
||||
/**
|
||||
* Preserve `name` property for functions.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
function: boolean
|
||||
/**
|
||||
* Preserve `name` property for classes.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
class: boolean
|
||||
}
|
||||
|
||||
/** Minify synchronously. */
|
||||
export declare function minify(filename: string, sourceText: string, options?: MinifyOptions | undefined | null): MinifyResult
|
||||
|
||||
export interface MinifyOptions {
|
||||
/** Use when minifying an ES6 module. */
|
||||
module?: boolean
|
||||
compress?: boolean | CompressOptions
|
||||
mangle?: boolean | MangleOptions
|
||||
codegen?: boolean | CodegenOptions
|
||||
sourcemap?: boolean
|
||||
}
|
||||
|
||||
export interface MinifyResult {
|
||||
code: string
|
||||
map?: SourceMap
|
||||
errors: Array<OxcError>
|
||||
}
|
||||
export interface Comment {
|
||||
type: 'Line' | 'Block'
|
||||
value: string
|
||||
start: number
|
||||
end: number
|
||||
}
|
||||
|
||||
export interface ErrorLabel {
|
||||
message?: string
|
||||
start: number
|
||||
end: number
|
||||
}
|
||||
|
||||
export interface OxcError {
|
||||
severity: Severity
|
||||
message: string
|
||||
labels: Array<ErrorLabel>
|
||||
helpMessage?: string
|
||||
codeframe?: string
|
||||
}
|
||||
|
||||
export declare const enum Severity {
|
||||
Error = 'Error',
|
||||
Warning = 'Warning',
|
||||
Advice = 'Advice'
|
||||
}
|
||||
export interface SourceMap {
|
||||
file?: string
|
||||
mappings: string
|
||||
names: Array<string>
|
||||
sourceRoot?: string
|
||||
sources: Array<string>
|
||||
sourcesContent?: Array<string>
|
||||
version: number
|
||||
x_google_ignoreList?: Array<number>
|
||||
}
|
||||
+406
@@ -0,0 +1,406 @@
|
||||
// prettier-ignore
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
import { createRequire } from 'node:module'
|
||||
const require = createRequire(import.meta.url)
|
||||
const __dirname = new URL('.', import.meta.url).pathname
|
||||
|
||||
const { readFileSync } = require('node:fs')
|
||||
let nativeBinding = null
|
||||
const loadErrors = []
|
||||
|
||||
const isMusl = () => {
|
||||
let musl = false
|
||||
if (process.platform === 'linux') {
|
||||
musl = isMuslFromFilesystem()
|
||||
if (musl === null) {
|
||||
musl = isMuslFromReport()
|
||||
}
|
||||
if (musl === null) {
|
||||
musl = isMuslFromChildProcess()
|
||||
}
|
||||
}
|
||||
return musl
|
||||
}
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
||||
|
||||
const isMuslFromFilesystem = () => {
|
||||
try {
|
||||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const isMuslFromReport = () => {
|
||||
let report = null
|
||||
if (typeof process.report?.getReport === 'function') {
|
||||
process.report.excludeNetwork = true
|
||||
report = process.report.getReport()
|
||||
}
|
||||
if (!report) {
|
||||
return null
|
||||
}
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return false
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const isMuslFromChildProcess = () => {
|
||||
try {
|
||||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
||||
} catch (e) {
|
||||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function requireNative() {
|
||||
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
||||
try {
|
||||
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
||||
} catch (err) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
} else if (process.platform === 'android') {
|
||||
if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./minify.android-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-android-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'arm') {
|
||||
try {
|
||||
return require('./minify.android-arm-eabi.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-android-arm-eabi')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'win32') {
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./minify.win32-x64-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-win32-x64-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'ia32') {
|
||||
try {
|
||||
return require('./minify.win32-ia32-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-win32-ia32-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./minify.win32-arm64-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-win32-arm64-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'darwin') {
|
||||
try {
|
||||
return require('./minify.darwin-universal.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-darwin-universal')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./minify.darwin-x64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-darwin-x64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./minify.darwin-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-darwin-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'freebsd') {
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./minify.freebsd-x64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-freebsd-x64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./minify.freebsd-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-freebsd-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'linux') {
|
||||
if (process.arch === 'x64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./minify.linux-x64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-x64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return require('./minify.linux-x64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-x64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'arm64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./minify.linux-arm64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return require('./minify.linux-arm64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'arm') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./minify.linux-arm-musleabihf.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm-musleabihf')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return require('./minify.linux-arm-gnueabihf.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm-gnueabihf')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'riscv64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./minify.linux-riscv64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-riscv64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return require('./minify.linux-riscv64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-riscv64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
}
|
||||
} else if (process.arch === 'ppc64') {
|
||||
try {
|
||||
return require('./minify.linux-ppc64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-ppc64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 's390x') {
|
||||
try {
|
||||
return require('./minify.linux-s390x-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-s390x-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'openharmony') {
|
||||
if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./minify.linux-arm64-ohos.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm64-ohos')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./minify.linux-x64-ohos.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-x64-ohos')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else if (process.arch === 'arm') {
|
||||
try {
|
||||
return require('./minify.linux-arm-ohos.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@oxc-minify/binding-linux-arm-ohos')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
||||
}
|
||||
}
|
||||
|
||||
nativeBinding = requireNative()
|
||||
|
||||
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
||||
try {
|
||||
nativeBinding = require('./minify.wasi.cjs')
|
||||
} catch (err) {
|
||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
}
|
||||
if (!nativeBinding) {
|
||||
try {
|
||||
nativeBinding = require('@oxc-minify/binding-wasm32-wasi')
|
||||
} catch (err) {
|
||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nativeBinding && globalThis.process?.versions?.["webcontainer"]) {
|
||||
try {
|
||||
nativeBinding = require('./webcontainer-fallback.js');
|
||||
} catch (err) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
if (loadErrors.length > 0) {
|
||||
throw new Error(
|
||||
`Cannot find native binding. ` +
|
||||
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
||||
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
||||
{ cause: loadErrors }
|
||||
)
|
||||
}
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
const { minify, Severity } = nativeBinding
|
||||
export { minify }
|
||||
export { Severity }
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "oxc-minify",
|
||||
"version": "0.87.0",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"browser": "browser.js",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"description": "Oxc Minifier Node API",
|
||||
"keywords": [
|
||||
"oxc",
|
||||
"minify"
|
||||
],
|
||||
"author": "Boshen and oxc contributors",
|
||||
"license": "MIT",
|
||||
"homepage": "https://oxc.rs",
|
||||
"bugs": "https://github.com/oxc-project/oxc/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/oxc-project/oxc.git",
|
||||
"directory": "napi/minify"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/Boshen"
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"browser.js",
|
||||
"webcontainer-fallback.js"
|
||||
],
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/",
|
||||
"access": "public"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vitest": "3.2.4",
|
||||
"typescript": "5.9.2"
|
||||
},
|
||||
"napi": {
|
||||
"binaryName": "minify",
|
||||
"packageName": "@oxc-minify/binding",
|
||||
"targets": [
|
||||
"x86_64-pc-windows-msvc",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-gnu",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-freebsd",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"armv7-unknown-linux-musleabihf",
|
||||
"s390x-unknown-linux-gnu",
|
||||
"riscv64gc-unknown-linux-gnu",
|
||||
"x86_64-apple-darwin",
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-linux-android",
|
||||
"wasm32-wasip1-threads"
|
||||
],
|
||||
"wasm": {
|
||||
"browser": {
|
||||
"fs": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@oxc-minify/binding-win32-x64-msvc": "0.87.0",
|
||||
"@oxc-minify/binding-win32-arm64-msvc": "0.87.0",
|
||||
"@oxc-minify/binding-linux-x64-gnu": "0.87.0",
|
||||
"@oxc-minify/binding-linux-x64-musl": "0.87.0",
|
||||
"@oxc-minify/binding-freebsd-x64": "0.87.0",
|
||||
"@oxc-minify/binding-linux-arm64-gnu": "0.87.0",
|
||||
"@oxc-minify/binding-linux-arm64-musl": "0.87.0",
|
||||
"@oxc-minify/binding-linux-arm-gnueabihf": "0.87.0",
|
||||
"@oxc-minify/binding-linux-arm-musleabihf": "0.87.0",
|
||||
"@oxc-minify/binding-linux-s390x-gnu": "0.87.0",
|
||||
"@oxc-minify/binding-linux-riscv64-gnu": "0.87.0",
|
||||
"@oxc-minify/binding-darwin-x64": "0.87.0",
|
||||
"@oxc-minify/binding-darwin-arm64": "0.87.0",
|
||||
"@oxc-minify/binding-android-arm64": "0.87.0",
|
||||
"@oxc-minify/binding-wasm32-wasi": "0.87.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build-dev": "napi build --esm --platform",
|
||||
"build-test": "pnpm run build-dev",
|
||||
"build": "pnpm run build-dev --features allocator --release",
|
||||
"postbuild-dev": "node patch.mjs",
|
||||
"test": "tsc && vitest run --dir ./test"
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
const fs = require('node:fs');
|
||||
const childProcess = require('node:child_process');
|
||||
|
||||
const pkg = JSON.parse(
|
||||
fs.readFileSync(require.resolve('oxc-minify/package.json'), 'utf-8'),
|
||||
);
|
||||
const version = pkg.version;
|
||||
const baseDir = `/tmp/oxc-minify-${version}`;
|
||||
const bindingEntry = `${baseDir}/node_modules/@oxc-minify/binding-wasm32-wasi/minify.wasi.cjs`;
|
||||
|
||||
if (!fs.existsSync(bindingEntry)) {
|
||||
fs.rmSync(baseDir, { recursive: true, force: true });
|
||||
fs.mkdirSync(baseDir, { recursive: true });
|
||||
const bindingPkg = `@oxc-minify/binding-wasm32-wasi@${version}`;
|
||||
// eslint-disable-next-line: no-console
|
||||
console.log(`[oxc-minify] Downloading ${bindingPkg} on WebContainer...`);
|
||||
childProcess.execFileSync('pnpm', ['i', bindingPkg], {
|
||||
cwd: baseDir,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = require(bindingEntry);
|
||||
Reference in New Issue
Block a user