File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66"use strict" ;
77
88const { createMappingsWriter } = require ( "./createMappingsSerializer" ) ;
9- const { createScopesWriter } = require ( "./scopes" ) ;
109
1110/** @typedef {import("../Source").RawSourceMap } RawSourceMap */
1211/** @typedef {import("../Source").SourceAndMap } SourceAndMap */
@@ -15,6 +14,20 @@ const { createScopesWriter } = require("./scopes");
1514
1615/** @typedef {{ streamChunks: StreamChunksFunction } } SourceLikeWithStreamChunks */
1716
17+ /** @type {typeof import("./scopes") | undefined } */
18+ let scopesHelpers ;
19+
20+ /**
21+ * Loads the scopes helpers on first use. They are only reachable through the
22+ * `scopes` option, so requiring them eagerly would put the encoder in the
23+ * module graph of every caller that never asks for the field.
24+ * @returns {ReturnType<typeof import("./scopes").createScopesWriter> } writer
25+ */
26+ const createScopesWriter = ( ) => {
27+ if ( scopesHelpers === undefined ) scopesHelpers = require ( "./scopes" ) ;
28+ return scopesHelpers . createScopesWriter ( ) ;
29+ } ;
30+
1831/**
1932 * Assign `value` at index `i` of `arr`, padding earlier slots with `null`.
2033 * Hoisted helper so `getMap` and `getSourceAndMap` share one
Original file line number Diff line number Diff line change 66"use strict" ;
77
88const { createMappingsWriter } = require ( "./createMappingsSerializer" ) ;
9- const { createScopesWriter } = require ( "./scopes" ) ;
109const streamChunks = require ( "./streamChunks" ) ;
1110
1211/** @typedef {import("../Source").RawSourceMap } RawSourceMap */
@@ -17,6 +16,20 @@ const streamChunks = require("./streamChunks");
1716/** @typedef {import("./streamChunks").Options } Options */
1817/** @typedef {import("./streamChunks").SourceMaybeWithStreamChunksFunction } SourceMaybeWithStreamChunksFunction */
1918
19+ /** @type {typeof import("./scopes") | undefined } */
20+ let scopesHelpers ;
21+
22+ /**
23+ * Loads the scopes helpers on first use. They are only reachable through the
24+ * `scopes` option, so requiring them eagerly would put the encoder in the
25+ * module graph of every caller that never asks for the field.
26+ * @returns {ReturnType<typeof import("./scopes").createScopesWriter> } writer
27+ */
28+ const createScopesWriter = ( ) => {
29+ if ( scopesHelpers === undefined ) scopesHelpers = require ( "./scopes" ) ;
30+ return scopesHelpers . createScopesWriter ( ) ;
31+ } ;
32+
2033/**
2134 * @param {SourceMaybeWithStreamChunksFunction } inputSource input source
2235 * @param {Options } options options
You can’t perform that action at this time.
0 commit comments