rolldown 1.0.0-beta.1-commit.1d4a330 → 1.0.0-beta.1-commit.298dd8b

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): 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
@@ -408,9 +444,9 @@ export interface BindingMatchGroup {
408
444
  export interface BindingModuleFederationPluginOption {
409
445
  name: string
410
446
  filename?: string
411
- expose: Record<string, string>
412
- remotes: Record<string, BindingRemote>
413
- shared: Record<string, BindingShared>
447
+ expose?: Record<string, string>
448
+ remotes?: Record<string, BindingRemote>
449
+ shared?: Record<string, BindingShared>
414
450
  }
415
451
 
416
452
  export interface BindingModulePreloadPolyfillPluginConfig {
@@ -540,7 +576,6 @@ export interface BindingPluginWithIndex {
540
576
 
541
577
  export interface BindingRemote {
542
578
  type?: string
543
- name: string
544
579
  entry: string
545
580
  entryGlobalName?: string
546
581
  shareScope?: string
@@ -569,7 +604,6 @@ export interface BindingResolveOptions {
569
604
  }
570
605
 
571
606
  export interface BindingShared {
572
- name: string
573
607
  version?: string
574
608
  shareScope?: string
575
609
  singleton?: boolean
@@ -640,6 +674,13 @@ export interface BindingWatchOption {
640
674
  exclude?: Array<BindingStringOrRegex>
641
675
  }
642
676
 
677
+ export interface Comment {
678
+ type: 'Line' | 'Block'
679
+ value: string
680
+ start: number
681
+ end: number
682
+ }
683
+
643
684
  export interface CompilerAssumptions {
644
685
  ignoreFunctionLength?: boolean
645
686
  noDocumentAll?: boolean
@@ -648,6 +689,23 @@ export interface CompilerAssumptions {
648
689
  setPublicClassFields?: boolean
649
690
  }
650
691
 
692
+ export interface EcmaScriptModule {
693
+ /**
694
+ * Has ESM syntax.
695
+ *
696
+ * i.e. `import` and `export` statements, and `import.meta`.
697
+ *
698
+ * Dynamic imports `import('foo')` are ignored since they can be used in non-ESM files.
699
+ */
700
+ hasModuleSyntax: boolean
701
+ /** Import Statements. */
702
+ staticImports: Array<StaticImport>
703
+ /** Export Statements. */
704
+ staticExports: Array<StaticExport>
705
+ /** Span positions` of `import.meta` */
706
+ importMetas: Array<Span>
707
+ }
708
+
651
709
  export interface ErrorLabel {
652
710
  message?: string
653
711
  start: number
@@ -659,6 +717,53 @@ export interface Es2015Options {
659
717
  arrowFunction?: ArrowFunctionsOptions
660
718
  }
661
719
 
720
+ export interface ExportExportName {
721
+ kind: ExportExportNameKind
722
+ name?: string
723
+ start?: number
724
+ end?: number
725
+ }
726
+
727
+ export type ExportExportNameKind = /** `export { name } */
728
+ 'Name'|
729
+ /** `export default expression` */
730
+ 'Default'|
731
+ /** `export * from "mod" */
732
+ 'None';
733
+
734
+ export interface ExportImportName {
735
+ kind: ExportImportNameKind
736
+ name?: string
737
+ start?: number
738
+ end?: number
739
+ }
740
+
741
+ export type ExportImportNameKind = /** `export { name } */
742
+ 'Name'|
743
+ /** `export * as ns from "mod"` */
744
+ 'All'|
745
+ /** `export * from "mod"` */
746
+ 'AllButDefault'|
747
+ /** Does not have a specifier. */
748
+ 'None';
749
+
750
+ export interface ExportLocalName {
751
+ kind: ExportLocalNameKind
752
+ name?: string
753
+ start?: number
754
+ end?: number
755
+ }
756
+
757
+ export type ExportLocalNameKind = /** `export { name } */
758
+ 'Name'|
759
+ /** `export default expression` */
760
+ 'Default'|
761
+ /**
762
+ * If the exported value is not locally accessible from within the module.
763
+ * `export default function () {}`
764
+ */
765
+ 'None';
766
+
662
767
  export interface ExtensionAliasItem {
663
768
  target: string
664
769
  replacements: Array<string>
@@ -690,6 +795,20 @@ export interface Helpers {
690
795
  mode?: HelperMode
691
796
  }
692
797
 
798
+ export interface ImportName {
799
+ kind: ImportNameKind
800
+ name?: string
801
+ start?: number
802
+ end?: number
803
+ }
804
+
805
+ export type ImportNameKind = /** `import { x } from "mod"` */
806
+ 'Name'|
807
+ /** `import * as ns from "mod"` */
808
+ 'NamespaceObject'|
809
+ /** `import defaultExport from "mod"` */
810
+ 'Default';
811
+
693
812
  /** TypeScript Isolated Declarations for Standalone DTS Emit */
694
813
  export declare function isolatedDeclaration(filename: string, sourceText: string, options?: IsolatedDeclarationsOptions | undefined | null): IsolatedDeclarationsResult
695
814
 
@@ -837,6 +956,15 @@ export interface JsxOptions {
837
956
  refresh?: boolean | ReactRefreshOptions
838
957
  }
839
958
 
959
+ export interface LineColumn {
960
+ line: number
961
+ column: number
962
+ }
963
+
964
+ export interface OverwriteOptions {
965
+ contentOnly: boolean
966
+ }
967
+
840
968
  export interface OxcError {
841
969
  severity: Severity
842
970
  message: string
@@ -844,6 +972,39 @@ export interface OxcError {
844
972
  helpMessage?: string
845
973
  }
846
974
 
975
+ /**
976
+ * Parse asynchronously.
977
+ *
978
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
979
+ */
980
+ export declare function parseAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
981
+
982
+ export interface ParserOptions {
983
+ sourceType?: 'script' | 'module' | 'unambiguous' | undefined
984
+ /** Treat the source text as `js`, `jsx`, `ts`, or `tsx`. */
985
+ lang?: 'js' | 'jsx' | 'ts' | 'tsx'
986
+ /**
987
+ * Emit `ParenthesizedExpression` in AST.
988
+ *
989
+ * If this option is true, parenthesized expressions are represented by
990
+ * (non-standard) `ParenthesizedExpression` nodes that have a single `expression` property
991
+ * containing the expression inside parentheses.
992
+ *
993
+ * Default: true
994
+ */
995
+ preserveParens?: boolean
996
+ }
997
+
998
+ /** Parse synchronously. */
999
+ export declare function parseSync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult
1000
+
1001
+ /**
1002
+ * Parse without returning anything.
1003
+ *
1004
+ * This is for benchmark purposes such as measuring napi communication overhead.
1005
+ */
1006
+ export declare function parseWithoutReturn(filename: string, sourceText: string, options?: ParserOptions | undefined | null): void
1007
+
847
1008
  export interface PreRenderedChunk {
848
1009
  name: string
849
1010
  isEntry: boolean
@@ -886,6 +1047,91 @@ export interface SourceMap {
886
1047
  x_google_ignoreList?: Array<number>
887
1048
  }
888
1049
 
1050
+ export interface SourceMapOptions {
1051
+ includeContent?: boolean
1052
+ source?: string
1053
+ hires?: boolean
1054
+ }
1055
+
1056
+ export interface Span {
1057
+ start: number
1058
+ end: number
1059
+ }
1060
+
1061
+ export interface StaticExport {
1062
+ start: number
1063
+ end: number
1064
+ entries: Array<StaticExportEntry>
1065
+ }
1066
+
1067
+ export interface StaticExportEntry {
1068
+ start: number
1069
+ end: number
1070
+ moduleRequest?: ValueSpan
1071
+ /** The name under which the desired binding is exported by the module`. */
1072
+ importName: ExportImportName
1073
+ /** The name used to export this binding by this module. */
1074
+ exportName: ExportExportName
1075
+ /** The name that is used to locally access the exported value from within the importing module. */
1076
+ localName: ExportLocalName
1077
+ }
1078
+
1079
+ export interface StaticImport {
1080
+ /** Start of import statement. */
1081
+ start: number
1082
+ /** End of import statement. */
1083
+ end: number
1084
+ /**
1085
+ * Import source.
1086
+ *
1087
+ * ```js
1088
+ * import { foo } from "mod";
1089
+ * // ^^^
1090
+ * ```
1091
+ */
1092
+ moduleRequest: ValueSpan
1093
+ /**
1094
+ * Import specifiers.
1095
+ *
1096
+ * Empty for `import "mod"`.
1097
+ */
1098
+ entries: Array<StaticImportEntry>
1099
+ }
1100
+
1101
+ export interface StaticImportEntry {
1102
+ /**
1103
+ * The name under which the desired binding is exported by the module.
1104
+ *
1105
+ * ```js
1106
+ * import { foo } from "mod";
1107
+ * // ^^^
1108
+ * import { foo as bar } from "mod";
1109
+ * // ^^^
1110
+ * ```
1111
+ */
1112
+ importName: ImportName
1113
+ /**
1114
+ * The name that is used to locally access the imported value from within the importing module.
1115
+ * ```js
1116
+ * import { foo } from "mod";
1117
+ * // ^^^
1118
+ * import { foo as bar } from "mod";
1119
+ * // ^^^
1120
+ * ```
1121
+ */
1122
+ localName: ValueSpan
1123
+ /**
1124
+ * Whether this binding is for a TypeScript type-only import.
1125
+ *
1126
+ * `true` for the following imports:
1127
+ * ```ts
1128
+ * import type { foo } from "mod";
1129
+ * import { type foo } from "mod";
1130
+ * ```
1131
+ */
1132
+ isType: boolean
1133
+ }
1134
+
889
1135
  /**
890
1136
  * Transpile a JavaScript or TypeScript into a target ECMAScript version.
891
1137
  *
@@ -1033,3 +1279,9 @@ export interface TypeScriptOptions {
1033
1279
  */
1034
1280
  rewriteImportExtensions?: 'rewrite' | 'remove' | boolean
1035
1281
  }
1282
+
1283
+ export interface ValueSpan {
1284
+ value: string
1285
+ start: number
1286
+ end: number
1287
+ }
@@ -1,4 +1,4 @@
1
- import { type BindingBuiltinPluginName, BindingGlobImportPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingJsonPluginConfig, BindingBuildImportAnalysisPluginConfig, type BindingViteResolvePluginConfig } from '../binding';
1
+ import { type BindingBuiltinPluginName, BindingGlobImportPluginConfig, BindingManifestPluginConfig, BindingModulePreloadPolyfillPluginConfig, BindingJsonPluginConfig, BindingBuildImportAnalysisPluginConfig, type BindingViteResolvePluginConfig, BindingModuleFederationPluginOption, BindingRemote } from '../binding';
2
2
  export declare class BuiltinPlugin {
3
3
  name: BindingBuiltinPluginName;
4
4
  _options?: unknown;
@@ -14,3 +14,7 @@ export declare function loadFallbackPlugin(): BuiltinPlugin;
14
14
  export declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
15
15
  export declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
16
16
  export declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, 'runtime'>): BuiltinPlugin;
17
+ export type ModuleFederationPluginOption = Omit<BindingModuleFederationPluginOption, 'remotes'> & {
18
+ remotes?: Record<string, string | BindingRemote>;
19
+ };
20
+ export declare function moduleFederationPlugin(config: ModuleFederationPluginOption): BuiltinPlugin;
@@ -3,7 +3,7 @@ export { experimental_scan as scan } from './api/experimental';
3
3
  export { transform } from './binding';
4
4
  export type { TransformOptions, TransformResult } from './binding';
5
5
  export { composeJsPlugins as composePlugins } from './utils/compose-js-plugins';
6
- export { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, wasmHelperPlugin, wasmFallbackPlugin, importGlobPlugin, manifestPlugin, loadFallbackPlugin, jsonPlugin, buildImportAnalysisPlugin, viteResolvePlugin, } from './builtin-plugin/constructors';
6
+ export { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, wasmHelperPlugin, wasmFallbackPlugin, importGlobPlugin, manifestPlugin, loadFallbackPlugin, jsonPlugin, buildImportAnalysisPlugin, viteResolvePlugin, moduleFederationPlugin, } from './builtin-plugin/constructors';
7
7
  export { transformPlugin } from './builtin-plugin/transform-plugin';
8
8
  export { replacePlugin } from './builtin-plugin/replace-plugin';
9
9
  export { aliasPlugin } from './builtin-plugin/alias-plugin';
@@ -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;
@@ -33,7 +40,7 @@ export declare class PluginContext extends MinimalPluginContext {
33
40
  resolveDependencies?: boolean;
34
41
  } & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
35
42
  resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
36
- emitFile(file: EmittedAsset): string;
43
+ emitFile(file: EmittedAsset | EmittedChunk): string;
37
44
  getFileName(referenceId: string): string;
38
45
  getModuleInfo(id: string): ModuleInfo | null;
39
46
  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.1d4a330",
3
+ "version": "1.0.0-beta.1-commit.298dd8b",
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
  },
@@ -112,22 +118,22 @@
112
118
  "type-fest": "^4.20.0",
113
119
  "unbuild": "^3.0.0",
114
120
  "why-is-node-running": "^3.0.0",
115
- "@rolldown/testing": "0.0.1",
116
- "rolldown": "1.0.0-beta.1-commit.1d4a330"
121
+ "rolldown": "1.0.0-beta.1-commit.298dd8b",
122
+ "@rolldown/testing": "0.0.1"
117
123
  },
118
124
  "optionalDependencies": {
119
- "@rolldown/binding-darwin-arm64": "1.0.0-beta.1-commit.1d4a330",
120
- "@rolldown/binding-freebsd-x64": "1.0.0-beta.1-commit.1d4a330",
121
- "@rolldown/binding-darwin-x64": "1.0.0-beta.1-commit.1d4a330",
122
- "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.1-commit.1d4a330",
123
- "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.1-commit.1d4a330",
124
- "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.1-commit.1d4a330",
125
- "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.1-commit.1d4a330",
126
- "@rolldown/binding-wasm32-wasi": "1.0.0-beta.1-commit.1d4a330",
127
- "@rolldown/binding-linux-x64-musl": "1.0.0-beta.1-commit.1d4a330",
128
- "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.1-commit.1d4a330",
129
- "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.1-commit.1d4a330",
130
- "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.1-commit.1d4a330"
125
+ "@rolldown/binding-darwin-x64": "1.0.0-beta.1-commit.298dd8b",
126
+ "@rolldown/binding-darwin-arm64": "1.0.0-beta.1-commit.298dd8b",
127
+ "@rolldown/binding-freebsd-x64": "1.0.0-beta.1-commit.298dd8b",
128
+ "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.1-commit.298dd8b",
129
+ "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.1-commit.298dd8b",
130
+ "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.1-commit.298dd8b",
131
+ "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.1-commit.298dd8b",
132
+ "@rolldown/binding-linux-x64-musl": "1.0.0-beta.1-commit.298dd8b",
133
+ "@rolldown/binding-wasm32-wasi": "1.0.0-beta.1-commit.298dd8b",
134
+ "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.1-commit.298dd8b",
135
+ "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.1-commit.298dd8b",
136
+ "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.1-commit.298dd8b"
131
137
  },
132
138
  "scripts": {
133
139
  "# Scrips for binding #": "_",