Skip to content

Commit

Permalink
chore: update wasm related configs (#7511)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen authored Nov 27, 2024
1 parent 6e48059 commit 8acab7f
Show file tree
Hide file tree
Showing 6 changed files with 820 additions and 869 deletions.
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ tasks/prettier_conformance/prettier/**
**/*.snap

crates/oxc_transformer/src/options/es_features.rs
npm/oxc-wasm/**
1 change: 1 addition & 0 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"napi/{parser,transform,minify}/index.d.ts",
"npm/*/package.json",
"npm/oxlint/configuration_schema.json",
"npm/oxc-wasm/**",
".github/.generated_ast_watch_list.yml"
],
"plugins": [
Expand Down
1 change: 1 addition & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ watch-wasm:

build-wasm mode="release":
wasm-pack build --out-dir ../../npm/oxc-wasm --target web --{{mode}} --scope oxc crates/oxc_wasm
echo '*.wasm' > npm/oxc-wasm/.gitignore
cp crates/oxc_wasm/package.json npm/oxc-wasm/package.json

# Generate the JavaScript global variables. See `tasks/javascript_globals`
Expand Down
2 changes: 1 addition & 1 deletion npm/oxc-wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.wasm
*.wasm
202 changes: 106 additions & 96 deletions npm/oxc-wasm/oxc_wasm.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,133 +7,145 @@
*/
export function browserslist(query: string, opts: any): any;
export interface OxcOptions {
run?: OxcRunOptions;
parser?: OxcParserOptions;
linter?: OxcLinterOptions;
transformer?: OxcTransformerOptions;
codegen?: OxcCodegenOptions;
minifier?: OxcMinifierOptions;
controlFlow?: OxcControlFlowOptions;
run?: OxcRunOptions;
parser?: OxcParserOptions;
linter?: OxcLinterOptions;
transformer?: OxcTransformerOptions;
codegen?: OxcCodegenOptions;
minifier?: OxcMinifierOptions;
controlFlow?: OxcControlFlowOptions;
}

export interface OxcRunOptions {
syntax?: boolean;
lint?: boolean;
format?: boolean;
prettierFormat?: boolean;
prettierIr?: boolean;
transform?: boolean;
typeCheck?: boolean;
scope?: boolean;
symbol?: boolean;
syntax?: boolean;
lint?: boolean;
format?: boolean;
prettierFormat?: boolean;
prettierIr?: boolean;
transform?: boolean;
typeCheck?: boolean;
scope?: boolean;
symbol?: boolean;
}

export interface OxcParserOptions {
allowReturnOutsideFunction?: boolean;
preserveParens?: boolean;
sourceType?: 'script' | 'module';
sourceFilename?: string;
allowReturnOutsideFunction?: boolean;
preserveParens?: boolean;
sourceType?: "script" | "module";
sourceFilename?: string;
}

export interface OxcLinterOptions {}

export interface OxcTransformerOptions {}

export interface OxcCodegenOptions {
indentation?: number;
enableTypescript?: boolean;
indentation?: number;
enableTypescript?: boolean;
}

export interface OxcControlFlowOptions {
verbose?: boolean;
verbose?: boolean;
}

export interface OxcMinifierOptions {
whitespace?: boolean;
mangle?: boolean;
compress?: boolean;
compressOptions?: OxcCompressOptions;
whitespace?: boolean;
mangle?: boolean;
compress?: boolean;
compressOptions?: OxcCompressOptions;
}

export interface OxcCompressOptions {
booleans: boolean;
drop_debugger: boolean;
drop_console: boolean;
evaluate: boolean;
join_vars: boolean;
loops: boolean;
typeofs: boolean;
booleans: boolean;
drop_debugger: boolean;
drop_console: boolean;
evaluate: boolean;
join_vars: boolean;
loops: boolean;
typeofs: boolean;
}

import type { Program, Span } from '@oxc-project/types';
export * from '@oxc-project/types';

import type { Program, Span } from "@oxc-project/types";
export * from "@oxc-project/types";


export interface Oxc {
ast: Program;
ir: string;
controlFlowGraph: string;
symbols: SymbolTable;
scopeText: string;
codegenText: string;
formattedText: string;
prettierFormattedText: string;
prettierIrText: string;
comments: Comment[];
diagnostics: Error[];
ast: Program;
ir: string;
controlFlowGraph: string;
symbols: SymbolTable;
scopeText: string;
codegenText: string;
formattedText: string;
prettierFormattedText: string;
prettierIrText: string;
comments: Comment[];
diagnostics: Error[];
}

export interface Comment {
type: CommentType;
value: string;
start: number;
end: number;
type: CommentType;
value: string;
start: number;
end: number;
}

export type CommentType = 'Line' | 'Block';
export type CommentType = "Line" | "Block";


export type IndexVec<I, T> = Array<T>;
export type CompactStr = string;


export interface SymbolTable {
spans: IndexVec<SymbolId, Span>;
names: IndexVec<SymbolId, CompactStr>;
flags: IndexVec<SymbolId, SymbolFlags>;
scopeIds: IndexVec<SymbolId, ScopeId>;
declarations: IndexVec<SymbolId, NodeId>;
resolvedReferences: IndexVec<SymbolId, ReferenceId[]>;
redeclarations: IndexVec<SymbolId, RedeclarationId | null>;
redeclarationSpans: IndexVec<RedeclarationId, Span[]>;
references: IndexVec<ReferenceId, Reference>;
spans: IndexVec<SymbolId, Span>;
names: IndexVec<SymbolId, CompactStr>;
flags: IndexVec<SymbolId, SymbolFlags>;
scopeIds: IndexVec<SymbolId, ScopeId>;
declarations: IndexVec<SymbolId, NodeId>;
resolvedReferences: IndexVec<SymbolId, ReferenceId[]>;
redeclarations: IndexVec<SymbolId, RedeclarationId | null>;
redeclarationSpans: IndexVec<RedeclarationId, Span[]>;
references: IndexVec<ReferenceId, Reference>;
}

export interface Reference {
nodeId: NodeId;
symbolId: SymbolId | null;
flags: ReferenceFlags;
nodeId: NodeId;
symbolId: SymbolId | null;
flags: ReferenceFlags;
}

export type NodeId = number;
export type NodeFlags = {
JSDoc: 1;
Class: 2;
HasYield: 4;
Parameter: 8;
};

export type ReferenceId = number;
export type ReferenceFlags = {
None: 0,
Read: 0b1,
Write: 0b10,
Type: 0b100,
Value: 0b11
}



export type ScopeId = number;



export type SymbolId = number;
export type SymbolFlags = unknown;
export type RedeclarationId = unknown;

export type ReferenceId = number;
export type ReferenceFlags = {
None: 0;
Read: 0b1;
Write: 0b10;
Type: 0b100;
Value: 0b11;


export type NodeId = number;
export type NodeFlags = {
JSDoc: 1,
Class: 2,
HasYield: 4
Parameter: 8
};

export type ScopeId = number;

export class Oxc {
free(): void;
Expand Down Expand Up @@ -188,23 +200,21 @@ export interface InitOutput {

export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;

/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init(
module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>,
): Promise<InitOutput>;
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
Loading

0 comments on commit 8acab7f

Please sign in to comment.