@rspack-canary/browser 1.6.0-canary-cf832f72-20251028084837 → 1.6.0-canary-505c7433-20251028174050

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.
@@ -5,6 +5,15 @@
5
5
  * @license MIT
6
6
  */
7
7
 
8
+ /*!
9
+ * The buffer module from node.js, for the browser.
10
+ *
11
+ * @author Feross Aboukhadijeh <https://feross.org>
12
+ * @license MIT
13
+ */
14
+
8
15
  /*! https://mths.be/punycode v1.4.1 by @mathias */
9
16
 
17
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
18
+
10
19
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -90,6 +90,11 @@ export interface RspackError extends Error {
90
90
  }
91
91
 
92
92
  export type DependencyLocation = SyntheticDependencyLocation | RealDependencyLocation;
93
+
94
+ export interface JsSource {
95
+ source: string | Buffer
96
+ map?: string
97
+ }
93
98
  /* -- banner.d.ts end -- */
94
99
 
95
100
  /* -- napi-rs generated below -- */
@@ -180,24 +185,24 @@ export declare class ConcatenatedModule {
180
185
  get rootModule(): Module
181
186
  get modules(): Module[]
182
187
  readableIdentifier(): string
183
- _originalSource(): JsCompatSource | undefined
188
+ _originalSource(): JsSource
184
189
  nameForCondition(): string | undefined
185
190
  get blocks(): AsyncDependenciesBlock[]
186
191
  get dependencies(): Dependency[]
187
192
  size(ty?: string | undefined | null): number
188
193
  libIdent(options: JsLibIdentOptions): string | null
189
- _emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
194
+ _emitFile(filename: string, source: JsSource, assetInfo?: AssetInfo | undefined | null): void
190
195
  }
191
196
 
192
197
  export declare class ContextModule {
193
198
  readableIdentifier(): string
194
- _originalSource(): JsCompatSource | undefined
199
+ _originalSource(): JsSource
195
200
  nameForCondition(): string | undefined
196
201
  get blocks(): AsyncDependenciesBlock[]
197
202
  get dependencies(): Dependency[]
198
203
  size(ty?: string | undefined | null): number
199
204
  libIdent(options: JsLibIdentOptions): string | null
200
- _emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
205
+ _emitFile(filename: string, source: JsSource, assetInfo?: AssetInfo | undefined | null): void
201
206
  }
202
207
 
203
208
  export declare class Dependency {
@@ -254,20 +259,20 @@ export type EntryOptionsDTO = EntryOptionsDto
254
259
 
255
260
  export declare class ExternalModule {
256
261
  readableIdentifier(): string
257
- _originalSource(): JsCompatSource | undefined
262
+ _originalSource(): JsSource
258
263
  nameForCondition(): string | undefined
259
264
  get blocks(): AsyncDependenciesBlock[]
260
265
  get dependencies(): Dependency[]
261
266
  size(ty?: string | undefined | null): number
262
267
  libIdent(options: JsLibIdentOptions): string | null
263
- _emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
268
+ _emitFile(filename: string, source: JsSource, assetInfo?: AssetInfo | undefined | null): void
264
269
  }
265
270
 
266
271
  export declare class JsCompilation {
267
- updateAsset(filename: string, newSourceOrFunction: JsCompatSource | ((source: JsCompatSourceOwned) => JsCompatSourceOwned), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo | undefined)): void
272
+ updateAsset(filename: string, newSourceOrFunction: JsSource | ((source: JsSource) => JsSource), assetInfoUpdateOrFunction?: AssetInfo | ((assetInfo: AssetInfo) => AssetInfo | undefined)): void
268
273
  getAssets(): Readonly<JsAsset>[]
269
274
  getAsset(name: string): JsAsset | null
270
- getAssetSource(name: string): JsCompatSource | null
275
+ getAssetSource(name: string): JsSource | null
271
276
  get modules(): Array<Module>
272
277
  get builtModules(): Array<Module>
273
278
  getOptimizationBailout(): Array<JsStatsOptimizationBailout>
@@ -276,11 +281,11 @@ export declare class JsCompilation {
276
281
  getNamedChunk(name: string): Chunk
277
282
  getNamedChunkGroupKeys(): Array<string>
278
283
  getNamedChunkGroup(name: string): ChunkGroup
279
- setAssetSource(name: string, source: JsCompatSource): void
284
+ setAssetSource(name: string, source: JsSource): void
280
285
  deleteAssetSource(name: string): void
281
286
  getAssetFilenames(): Array<string>
282
287
  hasAsset(name: string): boolean
283
- emitAsset(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
288
+ emitAsset(filename: string, source: JsSource, assetInfo?: AssetInfo | undefined | null): void
284
289
  deleteAsset(filename: string): void
285
290
  renameAsset(filename: string, newName: string): void
286
291
  get entrypoints(): ChunkGroup[]
@@ -425,13 +430,13 @@ export declare class KnownBuildInfo {
425
430
 
426
431
  export declare class Module {
427
432
  readableIdentifier(): string
428
- _originalSource(): JsCompatSource | undefined
433
+ _originalSource(): JsSource
429
434
  nameForCondition(): string | undefined
430
435
  get blocks(): AsyncDependenciesBlock[]
431
436
  get dependencies(): Dependency[]
432
437
  size(ty?: string | undefined | null): number
433
438
  libIdent(options: JsLibIdentOptions): string | null
434
- _emitFile(filename: string, source: JsCompatSource, assetInfo?: AssetInfo | undefined | null): void
439
+ _emitFile(filename: string, source: JsSource, assetInfo?: AssetInfo | undefined | null): void
435
440
  }
436
441
 
437
442
  export declare class ModuleGraphConnection {
@@ -486,7 +491,7 @@ export declare class ResolverFactory {
486
491
  }
487
492
 
488
493
  export declare class Sources {
489
- _get(sourceType: string): JsCompatSourceOwned | null
494
+ _get(sourceType: string): JsSource | null
490
495
  }
491
496
 
492
497
  export declare class VirtualFileStore {
@@ -760,23 +765,6 @@ export interface JsCodegenerationResults {
760
765
  map: Record<string, Record<string, JsCodegenerationResult>>
761
766
  }
762
767
 
763
- /**
764
- * Zero copy `JsCompatSource` slice shared between Rust and Node.js if buffer is used.
765
- *
766
- * It can only be used in non-async context and the lifetime is bound to the fn closure.
767
- *
768
- * If you want to use Node.js Buffer in async context or want to extend the lifetime, use `JsCompatSourceOwned` instead.
769
- */
770
- export interface JsCompatSource {
771
- source: string | Buffer
772
- map?: string
773
- }
774
-
775
- export interface JsCompatSourceOwned {
776
- source: string | Buffer
777
- map?: string
778
- }
779
-
780
768
  export interface JsCreateData {
781
769
  request: string
782
770
  userRequest: string
@@ -1206,7 +1194,7 @@ export interface JsRuntimeGlobals {
1206
1194
  }
1207
1195
 
1208
1196
  export interface JsRuntimeModule {
1209
- source?: JsCompatSourceOwned
1197
+ source?: JsSource
1210
1198
  moduleIdentifier: string
1211
1199
  constructorName: string
1212
1200
  name: string
@@ -1227,6 +1215,23 @@ export interface JsRuntimeRequirementInTreeResult {
1227
1215
  allRuntimeRequirements: JsRuntimeGlobals
1228
1216
  }
1229
1217
 
1218
+ /**
1219
+ * Zero copy `JsSourceFromJs` slice shared between Rust and Node.js if buffer is used.
1220
+ *
1221
+ * It can only be used in non-async context and the lifetime is bound to the fn closure.
1222
+ *
1223
+ * If you want to use Node.js Buffer in async context or want to extend the lifetime, use `JsSourceToJs` instead.
1224
+ */
1225
+ export interface JsSourceFromJs {
1226
+ source: string | Buffer
1227
+ map?: string
1228
+ }
1229
+
1230
+ export interface JsSourceToJs {
1231
+ source: string | Buffer
1232
+ map?: string
1233
+ }
1234
+
1230
1235
  export interface JsStatsAsset {
1231
1236
  type: string
1232
1237
  name: string
@@ -1,104 +1,125 @@
1
- import { createOnMessage as __wasmCreateOnMessageForFsProxy, getDefaultContext as __emnapiGetDefaultContext, instantiateNapiModule as __emnapiInstantiateNapiModule, WASI as __WASI } from '@napi-rs/wasm-runtime';
2
- import { memfs, Buffer } from '@napi-rs/wasm-runtime/fs';
3
- export const { fs: __fs, vol: __volume } = memfs();
1
+ import {
2
+ createOnMessage as __wasmCreateOnMessageForFsProxy,
3
+ getDefaultContext as __emnapiGetDefaultContext,
4
+ instantiateNapiModule as __emnapiInstantiateNapiModule,
5
+ WASI as __WASI,
6
+ } from '@napi-rs/wasm-runtime'
7
+ import { memfs, Buffer } from '@napi-rs/wasm-runtime/fs'
8
+
9
+
10
+ export const { fs: __fs, vol: __volume } = memfs()
11
+
4
12
  const __wasi = new __WASI({
5
- version: 'preview1',
6
- fs: __fs,
7
- preopens: {
8
- '/': '/'
9
- }
10
- });
11
- const __wasmUrl = new URL('./rspack.wasm32-wasi.wasm', import.meta.url).href;
12
- const __emnapiContext = __emnapiGetDefaultContext();
13
- __emnapiContext.feature.Buffer = Buffer;
13
+ version: 'preview1',
14
+ fs: __fs,
15
+ preopens: {
16
+ '/': '/',
17
+ },
18
+ })
19
+
20
+ const __wasmUrl = window.RSPACK_WASM_URL || new URL('./rspack.wasm32-wasi.wasm', import.meta.url).href
21
+ const __emnapiContext = __emnapiGetDefaultContext()
22
+ __emnapiContext.feature.Buffer = Buffer
23
+
14
24
  const __sharedMemory = new WebAssembly.Memory({
15
- initial: 16384,
16
- maximum: 65536,
17
- shared: true
18
- });
19
- const __wasmFile = await fetch(__wasmUrl).then((res)=>res.arrayBuffer());
20
- const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = await __emnapiInstantiateNapiModule(__wasmFile, {
21
- context: __emnapiContext,
22
- asyncWorkPoolSize: 4,
23
- wasi: __wasi,
24
- onCreateWorker () {
25
- const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
26
- type: 'module'
27
- });
28
- worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs));
29
- return worker;
30
- },
31
- overwriteImports (importObject) {
32
- importObject.env = {
33
- ...importObject.env,
34
- ...importObject.napi,
35
- ...importObject.emnapi,
36
- memory: __sharedMemory
37
- };
38
- return importObject;
39
- },
40
- beforeInit ({ instance }) {
41
- for (const name of Object.keys(instance.exports))if (name.startsWith('__napi_register__')) instance.exports[name]();
25
+ initial: 16384,
26
+ maximum: 65536,
27
+ shared: true,
28
+ })
29
+
30
+ const __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
31
+
32
+ const {
33
+ instance: __napiInstance,
34
+ module: __wasiModule,
35
+ napiModule: __napiModule,
36
+ } = await __emnapiInstantiateNapiModule(__wasmFile, {
37
+ context: __emnapiContext,
38
+ asyncWorkPoolSize: 4,
39
+ wasi: __wasi,
40
+ onCreateWorker() {
41
+ const worker = new Worker(URL.createObjectURL(new Blob([`importScripts("${new URL('./wasi-worker-browser.mjs', import.meta.url)}")`], { type: 'text/javascript' })), {
42
+ type: 'classic',
43
+ })
44
+ worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
45
+
46
+ return worker
47
+ },
48
+ overwriteImports(importObject) {
49
+ importObject.env = {
50
+ ...importObject.env,
51
+ ...importObject.napi,
52
+ ...importObject.emnapi,
53
+ memory: __sharedMemory,
54
+ }
55
+ return importObject
56
+ },
57
+ beforeInit({ instance }) {
58
+ for (const name of Object.keys(instance.exports)) {
59
+ if (name.startsWith('__napi_register__')) {
60
+ instance.exports[name]()
61
+ }
42
62
  }
43
- });
44
- export default __napiModule.exports;
45
- export const Assets = __napiModule.exports.Assets;
46
- export const AsyncDependenciesBlock = __napiModule.exports.AsyncDependenciesBlock;
47
- export const Chunk = __napiModule.exports.Chunk;
48
- export const ChunkGraph = __napiModule.exports.ChunkGraph;
49
- export const ChunkGroup = __napiModule.exports.ChunkGroup;
50
- export const Chunks = __napiModule.exports.Chunks;
51
- export const CodeGenerationResult = __napiModule.exports.CodeGenerationResult;
52
- export const CodeGenerationResults = __napiModule.exports.CodeGenerationResults;
53
- export const ConcatenatedModule = __napiModule.exports.ConcatenatedModule;
54
- export const ContextModule = __napiModule.exports.ContextModule;
55
- export const Dependency = __napiModule.exports.Dependency;
56
- export const Diagnostics = __napiModule.exports.Diagnostics;
57
- export const EntryDataDto = __napiModule.exports.EntryDataDto;
58
- export const EntryDataDTO = __napiModule.exports.EntryDataDTO;
59
- export const EntryDependency = __napiModule.exports.EntryDependency;
60
- export const EntryOptionsDto = __napiModule.exports.EntryOptionsDto;
61
- export const EntryOptionsDTO = __napiModule.exports.EntryOptionsDTO;
62
- export const ExternalModule = __napiModule.exports.ExternalModule;
63
- export const JsCompilation = __napiModule.exports.JsCompilation;
64
- export const JsCompiler = __napiModule.exports.JsCompiler;
65
- export const JsContextModuleFactoryAfterResolveData = __napiModule.exports.JsContextModuleFactoryAfterResolveData;
66
- export const JsContextModuleFactoryBeforeResolveData = __napiModule.exports.JsContextModuleFactoryBeforeResolveData;
67
- export const JsDependencies = __napiModule.exports.JsDependencies;
68
- export const JsEntries = __napiModule.exports.JsEntries;
69
- export const JsExportsInfo = __napiModule.exports.JsExportsInfo;
70
- export const JsModuleGraph = __napiModule.exports.JsModuleGraph;
71
- export const JsResolver = __napiModule.exports.JsResolver;
72
- export const JsResolverFactory = __napiModule.exports.JsResolverFactory;
73
- export const JsStats = __napiModule.exports.JsStats;
74
- export const KnownBuildInfo = __napiModule.exports.KnownBuildInfo;
75
- export const Module = __napiModule.exports.Module;
76
- export const ModuleGraphConnection = __napiModule.exports.ModuleGraphConnection;
77
- export const NativeWatcher = __napiModule.exports.NativeWatcher;
78
- export const NativeWatchResult = __napiModule.exports.NativeWatchResult;
79
- export const NormalModule = __napiModule.exports.NormalModule;
80
- export const RawExternalItemFnCtx = __napiModule.exports.RawExternalItemFnCtx;
81
- export const ReadonlyResourceData = __napiModule.exports.ReadonlyResourceData;
82
- export const ResolverFactory = __napiModule.exports.ResolverFactory;
83
- export const Sources = __napiModule.exports.Sources;
84
- export const VirtualFileStore = __napiModule.exports.VirtualFileStore;
85
- export const JsVirtualFileStore = __napiModule.exports.JsVirtualFileStore;
86
- export const async = __napiModule.exports.async;
87
- export const BuiltinPluginName = __napiModule.exports.BuiltinPluginName;
88
- export const cleanupGlobalTrace = __napiModule.exports.cleanupGlobalTrace;
89
- export const EnforceExtension = __napiModule.exports.EnforceExtension;
90
- export const EXPECTED_RSPACK_CORE_VERSION = __napiModule.exports.EXPECTED_RSPACK_CORE_VERSION;
91
- export const formatDiagnostic = __napiModule.exports.formatDiagnostic;
92
- export const JsLoaderState = __napiModule.exports.JsLoaderState;
93
- export const JsRspackSeverity = __napiModule.exports.JsRspackSeverity;
94
- export const loadBrowserslist = __napiModule.exports.loadBrowserslist;
95
- export const minify = __napiModule.exports.minify;
96
- export const minifySync = __napiModule.exports.minifySync;
97
- export const RawJavascriptParserCommonjsExports = __napiModule.exports.RawJavascriptParserCommonjsExports;
98
- export const RawRuleSetConditionType = __napiModule.exports.RawRuleSetConditionType;
99
- export const registerGlobalTrace = __napiModule.exports.registerGlobalTrace;
100
- export const RegisterJsTapKind = __napiModule.exports.RegisterJsTapKind;
101
- export const sync = __napiModule.exports.sync;
102
- export const syncTraceEvent = __napiModule.exports.syncTraceEvent;
103
- export const transform = __napiModule.exports.transform;
104
- export const transformSync = __napiModule.exports.transformSync;
63
+ },
64
+ })
65
+ export default __napiModule.exports
66
+ export const Assets = __napiModule.exports.Assets
67
+ export const AsyncDependenciesBlock = __napiModule.exports.AsyncDependenciesBlock
68
+ export const Chunk = __napiModule.exports.Chunk
69
+ export const ChunkGraph = __napiModule.exports.ChunkGraph
70
+ export const ChunkGroup = __napiModule.exports.ChunkGroup
71
+ export const Chunks = __napiModule.exports.Chunks
72
+ export const CodeGenerationResult = __napiModule.exports.CodeGenerationResult
73
+ export const CodeGenerationResults = __napiModule.exports.CodeGenerationResults
74
+ export const ConcatenatedModule = __napiModule.exports.ConcatenatedModule
75
+ export const ContextModule = __napiModule.exports.ContextModule
76
+ export const Dependency = __napiModule.exports.Dependency
77
+ export const Diagnostics = __napiModule.exports.Diagnostics
78
+ export const EntryDataDto = __napiModule.exports.EntryDataDto
79
+ export const EntryDataDTO = __napiModule.exports.EntryDataDTO
80
+ export const EntryDependency = __napiModule.exports.EntryDependency
81
+ export const EntryOptionsDto = __napiModule.exports.EntryOptionsDto
82
+ export const EntryOptionsDTO = __napiModule.exports.EntryOptionsDTO
83
+ export const ExternalModule = __napiModule.exports.ExternalModule
84
+ export const JsCompilation = __napiModule.exports.JsCompilation
85
+ export const JsCompiler = __napiModule.exports.JsCompiler
86
+ export const JsContextModuleFactoryAfterResolveData = __napiModule.exports.JsContextModuleFactoryAfterResolveData
87
+ export const JsContextModuleFactoryBeforeResolveData = __napiModule.exports.JsContextModuleFactoryBeforeResolveData
88
+ export const JsDependencies = __napiModule.exports.JsDependencies
89
+ export const JsEntries = __napiModule.exports.JsEntries
90
+ export const JsExportsInfo = __napiModule.exports.JsExportsInfo
91
+ export const JsModuleGraph = __napiModule.exports.JsModuleGraph
92
+ export const JsResolver = __napiModule.exports.JsResolver
93
+ export const JsResolverFactory = __napiModule.exports.JsResolverFactory
94
+ export const JsStats = __napiModule.exports.JsStats
95
+ export const KnownBuildInfo = __napiModule.exports.KnownBuildInfo
96
+ export const Module = __napiModule.exports.Module
97
+ export const ModuleGraphConnection = __napiModule.exports.ModuleGraphConnection
98
+ export const NativeWatcher = __napiModule.exports.NativeWatcher
99
+ export const NativeWatchResult = __napiModule.exports.NativeWatchResult
100
+ export const NormalModule = __napiModule.exports.NormalModule
101
+ export const RawExternalItemFnCtx = __napiModule.exports.RawExternalItemFnCtx
102
+ export const ReadonlyResourceData = __napiModule.exports.ReadonlyResourceData
103
+ export const ResolverFactory = __napiModule.exports.ResolverFactory
104
+ export const Sources = __napiModule.exports.Sources
105
+ export const VirtualFileStore = __napiModule.exports.VirtualFileStore
106
+ export const JsVirtualFileStore = __napiModule.exports.JsVirtualFileStore
107
+ export const async = __napiModule.exports.async
108
+ export const BuiltinPluginName = __napiModule.exports.BuiltinPluginName
109
+ export const cleanupGlobalTrace = __napiModule.exports.cleanupGlobalTrace
110
+ export const EnforceExtension = __napiModule.exports.EnforceExtension
111
+ export const EXPECTED_RSPACK_CORE_VERSION = __napiModule.exports.EXPECTED_RSPACK_CORE_VERSION
112
+ export const formatDiagnostic = __napiModule.exports.formatDiagnostic
113
+ export const JsLoaderState = __napiModule.exports.JsLoaderState
114
+ export const JsRspackSeverity = __napiModule.exports.JsRspackSeverity
115
+ export const loadBrowserslist = __napiModule.exports.loadBrowserslist
116
+ export const minify = __napiModule.exports.minify
117
+ export const minifySync = __napiModule.exports.minifySync
118
+ export const RawJavascriptParserCommonjsExports = __napiModule.exports.RawJavascriptParserCommonjsExports
119
+ export const RawRuleSetConditionType = __napiModule.exports.RawRuleSetConditionType
120
+ export const registerGlobalTrace = __napiModule.exports.registerGlobalTrace
121
+ export const RegisterJsTapKind = __napiModule.exports.RegisterJsTapKind
122
+ export const sync = __napiModule.exports.sync
123
+ export const syncTraceEvent = __napiModule.exports.syncTraceEvent
124
+ export const transform = __napiModule.exports.transform
125
+ export const transformSync = __napiModule.exports.transformSync
Binary file
@@ -1,7 +1,6 @@
1
- import type { JsCompatSourceOwned } from "../binding";
2
- import { Source } from "webpack-sources";
3
- declare class JsSource extends Source {
4
- static __from_binding(source: JsCompatSourceOwned): Source;
5
- static __to_binding(source: Source): JsCompatSourceOwned;
1
+ import type { JsSource } from "../binding";
2
+ import { type Source } from "webpack-sources";
3
+ export declare class SourceAdapter {
4
+ static fromBinding(source: JsSource): Source;
5
+ static toBinding(source: Source): JsSource;
6
6
  }
7
- export { JsSource };