rolldown 1.0.0-beta.3-commit.62fba31 → 1.0.0-beta.3-commit.4666fd5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -405,9 +405,12 @@ export interface BindingJsWatchChangeEvent {
405
405
  event: string
406
406
  }
407
407
 
408
+ /** TODO: support `preserve-react` mode */
408
409
  export type BindingJsx =
409
410
  | { type: 'Disable' }
410
411
  | { type: 'Preserve' }
412
+ | { type: 'React' }
413
+ | { type: 'ReactJsx' }
411
414
  | { type: 'Enable', field0: JsxOptions }
412
415
 
413
416
  export interface BindingLog {
@@ -823,6 +826,14 @@ export interface ExtensionAliasItem {
823
826
  replacements: Array<string>
824
827
  }
825
828
 
829
+ /**
830
+ * Get offset within a `Uint8Array` which is aligned on 4 GiB.
831
+ *
832
+ * Does not check that the offset is within bounds of `buffer`.
833
+ * To ensure it always is, provide a `Uint8Array` of at least 4 GiB size.
834
+ */
835
+ export declare function getBufferOffset(buffer: Uint8Array): number
836
+
826
837
  export type HelperMode = /**
827
838
  * Runtime mode (default): Helper functions are imported from a runtime package.
828
839
  *
@@ -1010,6 +1021,59 @@ export interface JsxOptions {
1010
1021
  refresh?: boolean | ReactRefreshOptions
1011
1022
  }
1012
1023
 
1024
+ /**
1025
+ * Transform JavaScript code to a Vite Node runnable module.
1026
+ *
1027
+ * @param filename The name of the file being transformed.
1028
+ * @param sourceText the source code itself
1029
+ * @param options The options for the transformation. See {@link
1030
+ * ModuleRunnerTransformOptions} for more information.
1031
+ *
1032
+ * @returns an object containing the transformed code, source maps, and any
1033
+ * errors that occurred during parsing or transformation.
1034
+ *
1035
+ * @deprecated Only works for Vite.
1036
+ */
1037
+ export declare function moduleRunnerTransform(filename: string, sourceText: string, options?: ModuleRunnerTransformOptions | undefined | null): ModuleRunnerTransformResult
1038
+
1039
+ export interface ModuleRunnerTransformOptions {
1040
+ /**
1041
+ * Enable source map generation.
1042
+ *
1043
+ * When `true`, the `sourceMap` field of transform result objects will be populated.
1044
+ *
1045
+ * @default false
1046
+ *
1047
+ * @see {@link SourceMap}
1048
+ */
1049
+ sourcemap?: boolean
1050
+ }
1051
+
1052
+ export interface ModuleRunnerTransformResult {
1053
+ /**
1054
+ * The transformed code.
1055
+ *
1056
+ * If parsing failed, this will be an empty string.
1057
+ */
1058
+ code: string
1059
+ /**
1060
+ * The source map for the transformed code.
1061
+ *
1062
+ * This will be set if {@link TransformOptions#sourcemap} is `true`.
1063
+ */
1064
+ map?: SourceMap
1065
+ deps: Array<string>
1066
+ dynamicDeps: Array<string>
1067
+ /**
1068
+ * Parse and transformation errors.
1069
+ *
1070
+ * Oxc's parser recovers from common syntax errors, meaning that
1071
+ * transformed code may still be available even if there are errors in this
1072
+ * list.
1073
+ */
1074
+ errors: Array<OxcError>
1075
+ }
1076
+
1013
1077
  export interface OxcError {
1014
1078
  severity: Severity
1015
1079
  message: string
@@ -1028,6 +1092,14 @@ export interface ParserOptions {
1028
1092
  sourceType?: 'script' | 'module' | 'unambiguous' | undefined
1029
1093
  /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
1030
1094
  lang?: 'js' | 'jsx' | 'ts' | 'tsx'
1095
+ /**
1096
+ * Return an AST which includes TypeScript-related properties, or excludes them.
1097
+ *
1098
+ * `'js'` is default for JS / JSX files.
1099
+ * `'ts'` is default for TS / TSX files.
1100
+ * The type of the file is determined from `lang` option, or extension of provided `filename`.
1101
+ */
1102
+ astType?: 'js' | 'ts'
1031
1103
  /**
1032
1104
  * Emit `ParenthesizedExpression` in AST.
1033
1105
  *
@@ -1035,20 +1107,49 @@ export interface ParserOptions {
1035
1107
  * (non-standard) `ParenthesizedExpression` nodes that have a single `expression` property
1036
1108
  * containing the expression inside parentheses.
1037
1109
  *
1038
- * Default: true
1110
+ * @default true
1039
1111
  */
1040
1112
  preserveParens?: boolean
1113
+ /**
1114
+ * Produce semantic errors with an additional AST pass.
1115
+ * Semantic errors depend on symbols and scopes, where the parser does not construct.
1116
+ * This adds a small performance overhead.
1117
+ *
1118
+ * @default false
1119
+ */
1120
+ showSemanticErrors?: boolean
1041
1121
  }
1042
1122
 
1043
1123
  /** Parse synchronously. */
1044
1124
  export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
1045
1125
 
1046
1126
  /**
1047
- * Parse without returning anything.
1127
+ * Parses AST into provided `Uint8Array` buffer.
1128
+ *
1129
+ * Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
1130
+ * provided as `source_len`.
1048
1131
  *
1049
- * This is for benchmark purposes such as measuring napi communication overhead.
1132
+ * This function will parse the source, and write the AST into the buffer, starting at the end.
1133
+ *
1134
+ * It also writes to the very end of the buffer the offset of `Program` within the buffer.
1135
+ *
1136
+ * Caller can deserialize data from the buffer on JS side.
1137
+ *
1138
+ * # SAFETY
1139
+ *
1140
+ * Caller must ensure:
1141
+ * * Source text is written into start of the buffer.
1142
+ * * Source text's UTF-8 byte length is `source_len`.
1143
+ * * The 1st `source_len` bytes of the buffer comprises a valid UTF-8 string.
1144
+ *
1145
+ * If source text is originally a JS string on JS side, and converted to a buffer with
1146
+ * `Buffer.from(str)` or `new TextEncoder().encode(str)`, this guarantees it's valid UTF-8.
1147
+ *
1148
+ * # Panics
1149
+ *
1150
+ * Panics if source text is too long, or AST takes more memory than is available in the buffer.
1050
1151
  */
1051
- export declare function parseWithoutReturn(filename: string, sourceText: string, options?: ParserOptions | undefined | null): void
1152
+ export declare function parseSyncRaw(filename: string, buffer: Uint8Array, sourceLen: number, options?: ParserOptions | undefined | null): void
1052
1153
 
1053
1154
  export interface PreRenderedChunk {
1054
1155
  name: string
@@ -1059,6 +1160,9 @@ export interface PreRenderedChunk {
1059
1160
  exports: Array<string>
1060
1161
  }
1061
1162
 
1163
+ /** Returns `true` if raw transfer is supported on this platform. */
1164
+ export declare function rawTransferSupported(): boolean
1165
+
1062
1166
  export interface ReactRefreshOptions {
1063
1167
  /**
1064
1168
  * Specify the identifier of the refresh registration variable.
@@ -1,3 +1,5 @@
1
1
  import type { ConfigExport } from '../types/config-export';
2
2
  export declare function loadTsConfig(configFile: string): Promise<ConfigExport>;
3
+ export declare function isFilePathESM(filePath: string): boolean;
4
+ export declare function findNearestPackageData(basedir: string): any | null;
3
5
  export declare function loadConfig(configPath: string): Promise<ConfigExport>;
@@ -23,7 +23,6 @@ export interface WatchOptions {
23
23
  };
24
24
  include?: StringOrRegExp | StringOrRegExp[];
25
25
  exclude?: StringOrRegExp | StringOrRegExp[];
26
- chokidar?: any;
27
26
  }
28
27
  export interface ChecksOptions {
29
28
  /**
@@ -157,13 +156,14 @@ export interface InputOptions {
157
156
  inject?: Record<string, string | [string, string]>;
158
157
  profilerNames?: boolean;
159
158
  /**
160
- * The `false` is disabled jsx parser, it will give you a syntax error if you use jsx syntax
161
- * The `mode: preserve` is disabled jsx transformer, it perverse original jsx syntax in the output.
162
- * The `mode: classic` is enabled jsx `classic` transformer.
163
- * The `mode: automatic` is enabled jsx `automatic` transformer.
164
- * @default mode = 'automatic'
159
+ * - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
160
+ * - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
161
+ * - `"react"` enables the `classic` JSX transformer.
162
+ * - `"react-jsx"` enables the `automatic` JSX transformer.
163
+ *
164
+ * @default mode = "automatic"
165
165
  */
166
- jsx?: false | JsxOptions;
166
+ jsx?: false | 'react' | 'react-jsx' | 'preserve' | JsxOptions;
167
167
  watch?: WatchOptions | false;
168
168
  dropLabels?: string[];
169
169
  keepNames?: boolean;
@@ -1,7 +1,6 @@
1
1
  import type { ObjectSchema } from '../types/schema';
2
- import type { TreeshakingOptions } from '../types/module-side-effects';
3
- export declare function validateTreeShakingOptions(options: TreeshakingOptions): void;
4
2
  export declare function validateCliOptions<T>(options: T): [T, string[]?];
3
+ export declare function validateOption<T>(key: 'input' | 'output', options: T): void;
5
4
  export declare function getInputCliKeys(): string[];
6
5
  export declare function getOutputCliKeys(): string[];
7
6
  export declare function getJsonSchema(): ObjectSchema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown",
3
- "version": "1.0.0-beta.3-commit.62fba31",
3
+ "version": "1.0.0-beta.3-commit.4666fd5",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "repository": {
@@ -84,12 +84,12 @@
84
84
  "dtsHeader": "type MaybePromise<T> = T | Promise<T>\ntype Nullable<T> = T | null | undefined\ntype VoidNullable<T = void> = T | null | undefined | void\nexport type BindingStringOrRegex = string | RegExp\n\n"
85
85
  },
86
86
  "dependencies": {
87
- "@oxc-project/types": "0.53.0",
87
+ "@oxc-project/types": "0.56.0",
88
88
  "@valibot/to-json-schema": "1.0.0-rc.0",
89
89
  "valibot": "1.0.0-rc.3"
90
90
  },
91
91
  "peerDependencies": {
92
- "@oxc-project/runtime": "0.53.0"
92
+ "@oxc-project/runtime": "0.56.0"
93
93
  },
94
94
  "peerDependenciesMeta": {
95
95
  "@oxc-project/runtime": {
@@ -122,26 +122,26 @@
122
122
  "unbuild": "^3.0.0",
123
123
  "why-is-node-running": "^3.0.0",
124
124
  "@rolldown/testing": "0.0.1",
125
- "rolldown": "1.0.0-beta.3-commit.62fba31"
125
+ "rolldown": "1.0.0-beta.3-commit.4666fd5"
126
126
  },
127
127
  "optionalDependencies": {
128
- "@rolldown/binding-darwin-arm64": "1.0.0-beta.3-commit.62fba31",
129
- "@rolldown/binding-darwin-x64": "1.0.0-beta.3-commit.62fba31",
130
- "@rolldown/binding-freebsd-x64": "1.0.0-beta.3-commit.62fba31",
131
- "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.3-commit.62fba31",
132
- "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.3-commit.62fba31",
133
- "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.3-commit.62fba31",
134
- "@rolldown/binding-wasm32-wasi": "1.0.0-beta.3-commit.62fba31",
135
- "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.3-commit.62fba31",
136
- "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.3-commit.62fba31",
137
- "@rolldown/binding-linux-x64-musl": "1.0.0-beta.3-commit.62fba31",
138
- "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.3-commit.62fba31",
139
- "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.3-commit.62fba31"
128
+ "@rolldown/binding-darwin-x64": "1.0.0-beta.3-commit.4666fd5",
129
+ "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.3-commit.4666fd5",
130
+ "@rolldown/binding-darwin-arm64": "1.0.0-beta.3-commit.4666fd5",
131
+ "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.3-commit.4666fd5",
132
+ "@rolldown/binding-freebsd-x64": "1.0.0-beta.3-commit.4666fd5",
133
+ "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.3-commit.4666fd5",
134
+ "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.3-commit.4666fd5",
135
+ "@rolldown/binding-wasm32-wasi": "1.0.0-beta.3-commit.4666fd5",
136
+ "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.3-commit.4666fd5",
137
+ "@rolldown/binding-linux-x64-musl": "1.0.0-beta.3-commit.4666fd5",
138
+ "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.3-commit.4666fd5",
139
+ "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.3-commit.4666fd5"
140
140
  },
141
141
  "scripts": {
142
142
  "# Scrips for binding #": "_",
143
143
  "artifacts": "napi artifacts --cwd ./src --package-json-path ../package.json -o=../artifacts --npm-dir ../npm",
144
- "build-binding": "napi build -o=./src --manifest-path ../../crates/rolldown_binding/Cargo.toml --platform -p rolldown_binding --js binding.js --dts binding.d.ts --no-const-enum --no-dts-cache",
144
+ "build-binding": "node ./build-binding.js",
145
145
  "build-binding:release": "pnpm build-binding --release",
146
146
  "build-binding:wasi": "pnpm build-binding --target wasm32-wasip1-threads",
147
147
  "build-binding:wasi:release": "pnpm build-binding --profile release-wasi --target wasm32-wasip1-threads",
@@ -149,8 +149,9 @@
149
149
  "bak_build-node": "unbuild",
150
150
  "build-node": "tsx ./build.ts",
151
151
  "build-types": "tsc -p ./tsconfig.json",
152
- "build-native:debug": "run-s build-binding build-types build-node build-types-check",
153
- "build-native:release": "run-s build-binding:release build-types build-node build-types-check",
152
+ "build-js-glue": "run-s build-types build-node build-types-check",
153
+ "build-native:debug": "run-s build-binding build-js-glue",
154
+ "build-native:release": "run-s build-binding:release build-js-glue",
154
155
  "build-wasi:debug": "run-s build-binding build-binding:wasi build-node",
155
156
  "build-wasi:release": "run-s build-binding build-binding:wasi:release build-node",
156
157
  "build-types-check": "tsc -p ./tsconfig.check.json",