rolldown 1.0.0-beta.1-commit.67a0051 → 1.0.0-beta.1-commit.2fe52d4

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.
@@ -104,6 +104,7 @@ export declare class BindingPluginContext {
104
104
  load(specifier: string, sideEffects: BindingHookSideEffects | undefined, fn: () => void): Promise<void>
105
105
  resolve(specifier: string, importer?: string | undefined | null, extraOptions?: BindingPluginContextResolveOptions | undefined | null): Promise<BindingPluginContextResolvedId | null>
106
106
  emitFile(file: BindingEmittedAsset): string
107
+ emitChunk(file: BindingEmittedChunk): Promise<string>
107
108
  getFileName(referenceId: string): string
108
109
  getModuleInfo(moduleId: string): BindingModuleInfo | null
109
110
  getModuleIds(): Array<string>
@@ -147,12 +148,40 @@ export declare class Bundler {
147
148
  get closed(): boolean
148
149
  }
149
150
 
151
+ export declare class MagicString {
152
+ /** Get source text from utf8 offset. */
153
+ getSourceText(start: number, end: number): string
154
+ /** Get 0-based line and column number from utf8 offset. */
155
+ getLineColumnNumber(offset: number): LineColumn
156
+ /** Get UTF16 byte offset from UTF8 byte offset. */
157
+ getUtf16ByteOffset(offset: number): number
158
+ length(): number
159
+ toString(): string
160
+ append(input: string): this
161
+ appendLeft(index: number, input: string): this
162
+ appendRight(index: number, input: string): this
163
+ indent(): this
164
+ prepend(input: string): this
165
+ prependLeft(index: number, input: string): this
166
+ prependRight(index: number, input: string): this
167
+ relocate(start: number, end: number, to: number): this
168
+ remove(start: number, end: number): this
169
+ }
170
+
150
171
  export declare class ParallelJsPluginRegistry {
151
172
  id: number
152
173
  workerCount: number
153
174
  constructor(workerCount: number)
154
175
  }
155
176
 
177
+ export declare class ParseResult {
178
+ get program(): import("@oxc-project/types").Program
179
+ get module(): EcmaScriptModule
180
+ get comments(): Array<Comment>
181
+ get errors(): Array<OxcError>
182
+ get magicString(): MagicString
183
+ }
184
+
156
185
  export declare class RenderedChunk {
157
186
  get name(): string
158
187
  get isEntry(): boolean
@@ -247,6 +276,13 @@ export interface BindingEmittedAsset {
247
276
  source: BindingAssetSource
248
277
  }
249
278
 
279
+ export interface BindingEmittedChunk {
280
+ name?: string
281
+ fileName?: string
282
+ id: string
283
+ importer?: string
284
+ }
285
+
250
286
  export interface BindingExperimentalOptions {
251
287
  strictExecutionOrder?: boolean
252
288
  disableLiveBindings?: boolean
@@ -640,6 +676,13 @@ export interface BindingWatchOption {
640
676
  exclude?: Array<BindingStringOrRegex>
641
677
  }
642
678
 
679
+ export interface Comment {
680
+ type: 'Line' | 'Block'
681
+ value: string
682
+ start: number
683
+ end: number
684
+ }
685
+
643
686
  export interface CompilerAssumptions {
644
687
  ignoreFunctionLength?: boolean
645
688
  noDocumentAll?: boolean
@@ -648,6 +691,23 @@ export interface CompilerAssumptions {
648
691
  setPublicClassFields?: boolean
649
692
  }
650
693
 
694
+ export interface EcmaScriptModule {
695
+ /**
696
+ * Has ESM syntax.
697
+ *
698
+ * i.e. `import` and `export` statements, and `import.meta`.
699
+ *
700
+ * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
701
+ */
702
+ hasModuleSyntax: boolean
703
+ /** Import Statements. */
704
+ staticImports: Array<StaticImport>
705
+ /** Export Statements. */
706
+ staticExports: Array<StaticExport>
707
+ /** Span positions` of `import.meta` */
708
+ importMetas: Array<Span>
709
+ }
710
+
651
711
  export interface ErrorLabel {
652
712
  message?: string
653
713
  start: number
@@ -659,6 +719,53 @@ export interface Es2015Options {
659
719
  arrowFunction?: ArrowFunctionsOptions
660
720
  }
661
721
 
722
+ export interface ExportExportName {
723
+ kind: ExportExportNameKind
724
+ name?: string
725
+ start?: number
726
+ end?: number
727
+ }
728
+
729
+ export type ExportExportNameKind = /** `export { name } */
730
+ 'Name'|
731
+ /** `export default expression` */
732
+ 'Default'|
733
+ /** `export * from "mod" */
734
+ 'None';
735
+
736
+ export interface ExportImportName {
737
+ kind: ExportImportNameKind
738
+ name?: string
739
+ start?: number
740
+ end?: number
741
+ }
742
+
743
+ export type ExportImportNameKind = /** `export { name } */
744
+ 'Name'|
745
+ /** `export * as ns from "mod"` */
746
+ 'All'|
747
+ /** `export * from "mod"` */
748
+ 'AllButDefault'|
749
+ /** Does not have a specifier. */
750
+ 'None';
751
+
752
+ export interface ExportLocalName {
753
+ kind: ExportLocalNameKind
754
+ name?: string
755
+ start?: number
756
+ end?: number
757
+ }
758
+
759
+ export type ExportLocalNameKind = /** `export { name } */
760
+ 'Name'|
761
+ /** `export default expression` */
762
+ 'Default'|
763
+ /**
764
+ * If the exported value is not locally accessible from within the module.
765
+ * `export default function () {}`
766
+ */
767
+ 'None';
768
+
662
769
  export interface ExtensionAliasItem {
663
770
  target: string
664
771
  replacements: Array<string>
@@ -690,6 +797,20 @@ export interface Helpers {
690
797
  mode?: HelperMode
691
798
  }
692
799
 
800
+ export interface ImportName {
801
+ kind: ImportNameKind
802
+ name?: string
803
+ start?: number
804
+ end?: number
805
+ }
806
+
807
+ export type ImportNameKind = /** `import { x } from "mod"` */
808
+ 'Name'|
809
+ /** `import * as ns from "mod"` */
810
+ 'NamespaceObject'|
811
+ /** `import defaultExport from "mod"` */
812
+ 'Default';
813
+
693
814
  /** TypeScript Isolated Declarations for Standalone DTS Emit */
694
815
  export declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult
695
816
 
@@ -837,6 +958,15 @@ export interface JsxOptions {
837
958
  refresh?: boolean | ReactRefreshOptions
838
959
  }
839
960
 
961
+ export interface LineColumn {
962
+ line: number
963
+ column: number
964
+ }
965
+
966
+ export interface OverwriteOptions {
967
+ contentOnly: boolean
968
+ }
969
+
840
970
  export interface OxcError {
841
971
  severity: Severity
842
972
  message: string
@@ -844,6 +974,39 @@ export interface OxcError {
844
974
  helpMessage?: string
845
975
  }
846
976
 
977
+ /**
978
+ * Parse asynchronously.
979
+ *
980
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
981
+ */
982
+ export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
983
+
984
+ export interface ParserOptions {
985
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined
986
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
987
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx'
988
+ /**
989
+ * Emit `ParenthesizedExpression` in AST.
990
+ *
991
+ * If this option is true, parenthesized expressions are represented by
992
+ * (non-standard) `ParenthesizedExpression` nodes that have a single `expression` property
993
+ * containing the expression inside parentheses.
994
+ *
995
+ * Default: true
996
+ */
997
+ preserveParens?: boolean
998
+ }
999
+
1000
+ /** Parse synchronously. */
1001
+ export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
1002
+
1003
+ /**
1004
+ * Parse without returning anything.
1005
+ *
1006
+ * This is for benchmark purposes such as measuring napi communication overhead.
1007
+ */
1008
+ export declare function parseWithoutReturn(filename: string, sourceText: string, options?: ParserOptions | undefined | null): void
1009
+
847
1010
  export interface PreRenderedChunk {
848
1011
  name: string
849
1012
  isEntry: boolean
@@ -886,6 +1049,91 @@ export interface SourceMap {
886
1049
  x_google_ignoreList?: Array<number>
887
1050
  }
888
1051
 
1052
+ export interface SourceMapOptions {
1053
+ includeContent?: boolean
1054
+ source?: string
1055
+ hires?: boolean
1056
+ }
1057
+
1058
+ export interface Span {
1059
+ start: number
1060
+ end: number
1061
+ }
1062
+
1063
+ export interface StaticExport {
1064
+ start: number
1065
+ end: number
1066
+ entries: Array<StaticExportEntry>
1067
+ }
1068
+
1069
+ export interface StaticExportEntry {
1070
+ start: number
1071
+ end: number
1072
+ moduleRequest?: ValueSpan
1073
+ /** The name under which the desired binding is exported by the module`. */
1074
+ importName: ExportImportName
1075
+ /** The name used to export this binding by this module. */
1076
+ exportName: ExportExportName
1077
+ /** The name that is used to locally access the exported value from within the importing module. */
1078
+ localName: ExportLocalName
1079
+ }
1080
+
1081
+ export interface StaticImport {
1082
+ /** Start of import statement. */
1083
+ start: number
1084
+ /** End of import statement. */
1085
+ end: number
1086
+ /**
1087
+ * Import source.
1088
+ *
1089
+ * ```js
1090
+ * import { foo } from "mod";
1091
+ * // ^^^
1092
+ * ```
1093
+ */
1094
+ moduleRequest: ValueSpan
1095
+ /**
1096
+ * Import specifiers.
1097
+ *
1098
+ * Empty for `import "mod"`.
1099
+ */
1100
+ entries: Array<StaticImportEntry>
1101
+ }
1102
+
1103
+ export interface StaticImportEntry {
1104
+ /**
1105
+ * The name under which the desired binding is exported by the module.
1106
+ *
1107
+ * ```js
1108
+ * import { foo } from "mod";
1109
+ * // ^^^
1110
+ * import { foo as bar } from "mod";
1111
+ * // ^^^
1112
+ * ```
1113
+ */
1114
+ importName: ImportName
1115
+ /**
1116
+ * The name that is used to locally access the imported value from within the importing module.
1117
+ * ```js
1118
+ * import { foo } from "mod";
1119
+ * // ^^^
1120
+ * import { foo as bar } from "mod";
1121
+ * // ^^^
1122
+ * ```
1123
+ */
1124
+ localName: ValueSpan
1125
+ /**
1126
+ * Whether this binding is for a TypeScript type-only import.
1127
+ *
1128
+ * `true` for the following imports:
1129
+ * ```ts
1130
+ * import type { foo } from "mod";
1131
+ * import { type foo } from "mod";
1132
+ * ```
1133
+ */
1134
+ isType: boolean
1135
+ }
1136
+
889
1137
  /**
890
1138
  * Transpile a JavaScript or TypeScript into a target ECMAScript version.
891
1139
  *
@@ -1033,3 +1281,9 @@ export interface TypeScriptOptions {
1033
1281
  */
1034
1282
  rewriteImportExtensions?: 'rewrite' | 'remove' | boolean
1035
1283
  }
1284
+
1285
+ export interface ValueSpan {
1286
+ value: string
1287
+ start: number
1288
+ end: number
1289
+ }
@@ -1,4 +1,5 @@
1
1
  import type { RollupLog } from '../types/misc';
2
+ export declare function logParseError(message: string): RollupLog;
2
3
  export declare function logMinifyWarning(): RollupLog;
3
4
  export declare function logInvalidLogPosition(pluginName: string): RollupLog;
4
5
  export declare function logInputHookInOutputPlugin(pluginName: string, hookName: string): RollupLog;
@@ -0,0 +1,4 @@
1
+ import type { ParseResult, ParserOptions } from './binding';
2
+ export declare function parseAst(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult;
3
+ export declare function parseAstAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>;
4
+ export type { ParseResult, ParserOptions };
@@ -14,6 +14,13 @@ export interface EmittedAsset {
14
14
  originalFileName?: string | null;
15
15
  source: AssetSource;
16
16
  }
17
+ export interface EmittedChunk {
18
+ type: 'chunk';
19
+ name?: string;
20
+ fileName?: string;
21
+ id: string;
22
+ importer?: string;
23
+ }
17
24
  export type EmittedFile = EmittedAsset;
18
25
  export interface PluginContextResolveOptions {
19
26
  skipSelf?: boolean;
@@ -34,6 +41,7 @@ export declare class PluginContext extends MinimalPluginContext {
34
41
  } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
35
42
  resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
36
43
  emitFile(file: EmittedAsset): string;
44
+ emitChunk(chunk: EmittedChunk): Promise<string>;
37
45
  getFileName(referenceId: string): string;
38
46
  getModuleInfo(id: string): ModuleInfo | null;
39
47
  getModuleIds(): IterableIterator<string>;
@@ -1,8 +1,8 @@
1
1
  import { Plugin } from './';
2
2
  import { InputOptions, OutputOptions, RolldownPlugin } from '..';
3
3
  export declare class PluginDriver {
4
- callOptionsHook(inputOptions: InputOptions): Promise<InputOptions>;
5
- callOutputOptionsHook(rawPlugins: RolldownPlugin[], outputOptions: OutputOptions): OutputOptions;
4
+ static callOptionsHook(inputOptions: InputOptions): Promise<InputOptions>;
5
+ static callOutputOptionsHook(rawPlugins: RolldownPlugin[], outputOptions: OutputOptions): OutputOptions;
6
6
  }
7
7
  export declare function getObjectPlugins(plugins: RolldownPlugin[]): Plugin[];
8
8
  export declare function getSortedPlugins(hookName: 'options' | 'outputOptions' | 'onLog', plugins: readonly Plugin[]): Plugin[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rolldown",
3
- "version": "1.0.0-beta.1-commit.67a0051",
3
+ "version": "1.0.0-beta.1-commit.2fe52d4",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "repository": {
@@ -44,6 +44,11 @@
44
44
  "require": "./dist/cjs/parallel-plugin.cjs",
45
45
  "import": "./dist/esm/parallel-plugin.mjs"
46
46
  },
47
+ "./parseAst": {
48
+ "types": "./dist/types/parse-ast-index.d.ts",
49
+ "require": "./dist/cjs/parse-ast-index.cjs",
50
+ "import": "./dist/esm/parse-ast-index.mjs"
51
+ },
47
52
  "./package.json": "./package.json"
48
53
  },
49
54
  "imports": {
@@ -79,6 +84,7 @@
79
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"
80
85
  },
81
86
  "dependencies": {
87
+ "@oxc-project/types": "0.45.0",
82
88
  "@valibot/to-json-schema": "1.0.0-beta.3",
83
89
  "valibot": "1.0.0-beta.9"
84
90
  },
@@ -113,21 +119,21 @@
113
119
  "unbuild": "^3.0.0",
114
120
  "why-is-node-running": "^3.0.0",
115
121
  "@rolldown/testing": "0.0.1",
116
- "rolldown": "1.0.0-beta.1-commit.67a0051"
122
+ "rolldown": "1.0.0-beta.1-commit.2fe52d4"
117
123
  },
118
124
  "optionalDependencies": {
119
- "@rolldown/binding-darwin-arm64": "1.0.0-beta.1-commit.67a0051",
120
- "@rolldown/binding-freebsd-x64": "1.0.0-beta.1-commit.67a0051",
121
- "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.1-commit.67a0051",
122
- "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.1-commit.67a0051",
123
- "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.1-commit.67a0051",
124
- "@rolldown/binding-darwin-x64": "1.0.0-beta.1-commit.67a0051",
125
- "@rolldown/binding-wasm32-wasi": "1.0.0-beta.1-commit.67a0051",
126
- "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.1-commit.67a0051",
127
- "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.1-commit.67a0051",
128
- "@rolldown/binding-linux-x64-musl": "1.0.0-beta.1-commit.67a0051",
129
- "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.1-commit.67a0051",
130
- "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.1-commit.67a0051"
125
+ "@rolldown/binding-darwin-x64": "1.0.0-beta.1-commit.2fe52d4",
126
+ "@rolldown/binding-darwin-arm64": "1.0.0-beta.1-commit.2fe52d4",
127
+ "@rolldown/binding-freebsd-x64": "1.0.0-beta.1-commit.2fe52d4",
128
+ "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.1-commit.2fe52d4",
129
+ "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.1-commit.2fe52d4",
130
+ "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.1-commit.2fe52d4",
131
+ "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.1-commit.2fe52d4",
132
+ "@rolldown/binding-linux-x64-musl": "1.0.0-beta.1-commit.2fe52d4",
133
+ "@rolldown/binding-wasm32-wasi": "1.0.0-beta.1-commit.2fe52d4",
134
+ "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.1-commit.2fe52d4",
135
+ "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.1-commit.2fe52d4",
136
+ "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.1-commit.2fe52d4"
131
137
  },
132
138
  "scripts": {
133
139
  "# Scrips for binding #": "_",