@wyw-in-js/transform 1.0.6 → 1.0.7
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.
- package/esm/cache.js +100 -7
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/module.js +51 -2
- package/esm/module.js.map +1 -1
- package/esm/plugins/shaker.js +152 -13
- package/esm/plugins/shaker.js.map +1 -1
- package/esm/shaker.js +51 -23
- package/esm/shaker.js.map +1 -1
- package/esm/transform/BaseEntrypoint.js +3 -1
- package/esm/transform/BaseEntrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.js +60 -17
- package/esm/transform/Entrypoint.js.map +1 -1
- package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
- package/esm/transform/barrelManifest.js +291 -0
- package/esm/transform/barrelManifest.js.map +1 -0
- package/esm/transform/generators/getExports.js +5 -0
- package/esm/transform/generators/getExports.js.map +1 -1
- package/esm/transform/generators/processEntrypoint.js +27 -1
- package/esm/transform/generators/processEntrypoint.js.map +1 -1
- package/esm/transform/generators/resolveImports.js +29 -5
- package/esm/transform/generators/resolveImports.js.map +1 -1
- package/esm/transform/generators/rewriteBarrelImports.js +733 -0
- package/esm/transform/generators/rewriteBarrelImports.js.map +1 -0
- package/esm/transform/generators/transform.js +154 -21
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/types.js.map +1 -1
- package/lib/cache.js +103 -7
- package/lib/cache.js.map +1 -1
- package/lib/debug/fileReporter.js.map +1 -1
- package/lib/module.js +51 -2
- package/lib/module.js.map +1 -1
- package/lib/plugins/shaker.js +152 -13
- package/lib/plugins/shaker.js.map +1 -1
- package/lib/shaker.js +58 -26
- package/lib/shaker.js.map +1 -1
- package/lib/transform/BaseEntrypoint.js +3 -1
- package/lib/transform/BaseEntrypoint.js.map +1 -1
- package/lib/transform/Entrypoint.js +61 -17
- package/lib/transform/Entrypoint.js.map +1 -1
- package/lib/transform/EvaluatedEntrypoint.js.map +1 -1
- package/lib/transform/barrelManifest.js +300 -0
- package/lib/transform/barrelManifest.js.map +1 -0
- package/lib/transform/generators/getExports.js +5 -0
- package/lib/transform/generators/getExports.js.map +1 -1
- package/lib/transform/generators/processEntrypoint.js +27 -1
- package/lib/transform/generators/processEntrypoint.js.map +1 -1
- package/lib/transform/generators/resolveImports.js +29 -5
- package/lib/transform/generators/resolveImports.js.map +1 -1
- package/lib/transform/generators/rewriteBarrelImports.js +743 -0
- package/lib/transform/generators/rewriteBarrelImports.js.map +1 -0
- package/lib/transform/generators/transform.js +158 -22
- package/lib/transform/generators/transform.js.map +1 -1
- package/lib/transform/types.js.map +1 -1
- package/package.json +8 -4
- package/types/cache.d.ts +16 -2
- package/types/cache.js +111 -7
- package/types/debug/fileReporter.d.ts +1 -0
- package/types/module.d.ts +3 -0
- package/types/module.js +57 -2
- package/types/plugins/shaker.js +161 -16
- package/types/shaker.d.ts +10 -1
- package/types/shaker.js +56 -28
- package/types/transform/BaseEntrypoint.d.ts +3 -1
- package/types/transform/BaseEntrypoint.js +5 -1
- package/types/transform/Entrypoint.d.ts +9 -0
- package/types/transform/Entrypoint.js +73 -20
- package/types/transform/EvaluatedEntrypoint.d.ts +2 -0
- package/types/transform/barrelManifest.d.ts +42 -0
- package/types/transform/barrelManifest.js +300 -0
- package/types/transform/generators/getExports.js +5 -0
- package/types/transform/generators/processEntrypoint.js +26 -1
- package/types/transform/generators/resolveImports.js +29 -5
- package/types/transform/generators/rewriteBarrelImports.d.ts +15 -0
- package/types/transform/generators/rewriteBarrelImports.js +815 -0
- package/types/transform/generators/transform.js +148 -19
- package/types/transform/types.d.ts +2 -0
|
@@ -4,14 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Entrypoint = void 0;
|
|
7
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
7
8
|
var _tsInvariant = require("ts-invariant");
|
|
8
9
|
var _BaseEntrypoint = require("./BaseEntrypoint");
|
|
9
10
|
var _Entrypoint = require("./Entrypoint.helpers");
|
|
10
|
-
var _isStaticallyEvaluatableModule = require("./isStaticallyEvaluatableModule");
|
|
11
11
|
var _EvaluatedEntrypoint = require("./EvaluatedEntrypoint");
|
|
12
12
|
var _AbortError = require("./actions/AbortError");
|
|
13
13
|
var _BaseAction = require("./actions/BaseAction");
|
|
14
14
|
var _UnprocessedEntrypointError = require("./actions/UnprocessedEntrypointError");
|
|
15
|
+
var _parseRequest = require("../utils/parseRequest");
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
17
|
const EMPTY_FILE = '=== empty file ===';
|
|
16
18
|
function hasLoop(name, parent, processed = []) {
|
|
17
19
|
if (parent.name === name || processed.includes(parent.name)) {
|
|
@@ -30,14 +32,18 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
30
32
|
onSupersedeHandlers = [];
|
|
31
33
|
actionsCache = new Map();
|
|
32
34
|
#hasWywMetadata = false;
|
|
35
|
+
#isProcessing = false;
|
|
36
|
+
#pendingOnly = null;
|
|
33
37
|
#supersededWith = null;
|
|
34
38
|
#transformResultCode = null;
|
|
35
|
-
constructor(services, parents, initialCode, name, only, exports, evaluatedOnly, loadedAndParsed, resolveTasks = new Map(), dependencies = new Map(), generation = 1) {
|
|
39
|
+
constructor(services, parents, initialCode, name, only, exports, evaluatedOnly, loadedAndParsed, resolveTasks = new Map(), dependencies = new Map(), invalidationDependencies = new Map(), invalidateOnDependencyChange = new Set(), generation = 1) {
|
|
36
40
|
var _parents$0$log, _parents$;
|
|
37
|
-
super(services, evaluatedOnly, exports, generation, name, only, parents, dependencies);
|
|
41
|
+
super(services, evaluatedOnly, exports, generation, name, only, parents, dependencies, invalidationDependencies, invalidateOnDependencyChange);
|
|
38
42
|
this.initialCode = initialCode;
|
|
39
43
|
this.resolveTasks = resolveTasks;
|
|
40
44
|
this.dependencies = dependencies;
|
|
45
|
+
this.invalidationDependencies = invalidationDependencies;
|
|
46
|
+
this.invalidateOnDependencyChange = invalidateOnDependencyChange;
|
|
41
47
|
this.loadedAndParsed = loadedAndParsed !== null && loadedAndParsed !== void 0 ? loadedAndParsed : services.loadAndParseFn(services, name, initialCode, (_parents$0$log = (_parents$ = parents[0]) === null || _parents$ === void 0 ? void 0 : _parents$.log) !== null && _parents$0$log !== void 0 ? _parents$0$log : services.log);
|
|
42
48
|
if (this.loadedAndParsed.code !== undefined) {
|
|
43
49
|
services.cache.invalidateIfChanged(name, this.loadedAndParsed.code, undefined, this.initialCode === undefined ? 'fs' : 'loaded');
|
|
@@ -102,7 +108,16 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
102
108
|
cache
|
|
103
109
|
} = services;
|
|
104
110
|
const cached = cache.get('entrypoints', name);
|
|
105
|
-
|
|
111
|
+
let changed = false;
|
|
112
|
+
if (loadedCode !== undefined) {
|
|
113
|
+
changed = cache.invalidateIfChanged(name, loadedCode, undefined, 'loaded');
|
|
114
|
+
} else if (cached && cached.initialCode === undefined) {
|
|
115
|
+
try {
|
|
116
|
+
changed = cache.invalidateIfChanged(name, _nodeFs.default.readFileSync((0, _parseRequest.stripQueryAndHash)(name), 'utf8'), undefined, 'fs');
|
|
117
|
+
} catch {
|
|
118
|
+
changed = false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
106
121
|
if (!(cached !== null && cached !== void 0 && cached.evaluated) && cached !== null && cached !== void 0 && cached.ignored) {
|
|
107
122
|
return ['cached', cached];
|
|
108
123
|
}
|
|
@@ -125,19 +140,14 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
125
140
|
return [isLoop ? 'loop' : 'cached', cached];
|
|
126
141
|
}
|
|
127
142
|
cached.log('is cached, but with different `only` %o (the cached one %o)', only, cached === null || cached === void 0 ? void 0 : cached.only);
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
ast
|
|
134
|
-
} = newEntrypoint.loadedAndParsed;
|
|
135
|
-
if (ast && (0, _isStaticallyEvaluatableModule.isStaticallyEvaluatableModule)(ast)) {
|
|
136
|
-
newEntrypoint.log('[entrypoint] promote `only` to "*" for statically evaluatable module');
|
|
137
|
-
newEntrypoint.only.length = 0;
|
|
138
|
-
newEntrypoint.only.push('*');
|
|
143
|
+
if (cached.#isProcessing) {
|
|
144
|
+
cached.deferOnlySupersede(mergedOnly);
|
|
145
|
+
cached.log('is being processed, defer supersede (%o -> %o)', cached.only, mergedOnly);
|
|
146
|
+
return [isLoop ? 'loop' : 'cached', cached];
|
|
139
147
|
}
|
|
148
|
+
return [isLoop ? 'loop' : 'created', cached.supersede(mergedOnly)];
|
|
140
149
|
}
|
|
150
|
+
const newEntrypoint = new Entrypoint(services, parent ? [parent] : [], loadedCode, name, mergedOnly, exports, evaluatedOnly, undefined, cached && 'resolveTasks' in cached ? cached.resolveTasks : undefined, cached && 'dependencies' in cached ? cached.dependencies : undefined, cached && 'invalidationDependencies' in cached ? cached.invalidationDependencies : undefined, cached && 'invalidateOnDependencyChange' in cached ? cached.invalidateOnDependencyChange : undefined, cached ? cached.generation + 1 : 1);
|
|
141
151
|
if (cached && !cached.evaluated) {
|
|
142
152
|
cached.log('is cached, but with different code');
|
|
143
153
|
cached.supersede(newEntrypoint);
|
|
@@ -148,9 +158,27 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
148
158
|
this.resolveTasks.delete(dependency.source);
|
|
149
159
|
this.dependencies.set(dependency.source, dependency);
|
|
150
160
|
}
|
|
161
|
+
addInvalidationDependency(dependency) {
|
|
162
|
+
this.resolveTasks.delete(dependency.source);
|
|
163
|
+
this.invalidationDependencies.set(dependency.source, dependency);
|
|
164
|
+
}
|
|
151
165
|
addResolveTask(name, dependency) {
|
|
152
166
|
this.resolveTasks.set(name, dependency);
|
|
153
167
|
}
|
|
168
|
+
applyDeferredSupersede() {
|
|
169
|
+
if (this.#supersededWith || this.#pendingOnly === null) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const mergedOnly = (0, _Entrypoint.mergeOnly)(this.only, this.#pendingOnly);
|
|
173
|
+
this.#pendingOnly = null;
|
|
174
|
+
if ((0, _Entrypoint.isSuperSet)(this.only, mergedOnly)) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
this.log('apply deferred supersede (%o -> %o)', this.only, mergedOnly);
|
|
178
|
+
const nextEntrypoint = this.supersede(mergedOnly);
|
|
179
|
+
this.services.cache.add('entrypoints', this.name, nextEntrypoint);
|
|
180
|
+
return nextEntrypoint;
|
|
181
|
+
}
|
|
154
182
|
assertNotSuperseded() {
|
|
155
183
|
if (this.supersededWith) {
|
|
156
184
|
this.log('superseded');
|
|
@@ -164,6 +192,9 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
164
192
|
throw new _UnprocessedEntrypointError.UnprocessedEntrypointError((_this$supersededWith3 = this.supersededWith) !== null && _this$supersededWith3 !== void 0 ? _this$supersededWith3 : this);
|
|
165
193
|
}
|
|
166
194
|
}
|
|
195
|
+
beginProcessing() {
|
|
196
|
+
this.#isProcessing = true;
|
|
197
|
+
}
|
|
167
198
|
createAction(actionType, data, abortSignal = null) {
|
|
168
199
|
var _cached$abortSignal;
|
|
169
200
|
if (!this.actionsCache.has(actionType)) {
|
|
@@ -189,13 +220,22 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
189
220
|
createEvaluated() {
|
|
190
221
|
const evaluatedOnly = (0, _Entrypoint.mergeOnly)(this.evaluatedOnly, this.only);
|
|
191
222
|
this.log('create EvaluatedEntrypoint for %o', evaluatedOnly);
|
|
192
|
-
const evaluated = new _EvaluatedEntrypoint.EvaluatedEntrypoint(this.services, evaluatedOnly, this.exportsProxy, this.generation + 1, this.name, this.only, this.parents, this.dependencies);
|
|
223
|
+
const evaluated = new _EvaluatedEntrypoint.EvaluatedEntrypoint(this.services, evaluatedOnly, this.exportsProxy, this.generation + 1, this.name, this.only, this.parents, this.dependencies, this.invalidationDependencies, this.invalidateOnDependencyChange);
|
|
193
224
|
evaluated.initialCode = this.initialCode;
|
|
194
225
|
return evaluated;
|
|
195
226
|
}
|
|
227
|
+
endProcessing() {
|
|
228
|
+
this.#isProcessing = false;
|
|
229
|
+
}
|
|
196
230
|
getDependency(name) {
|
|
197
231
|
return this.dependencies.get(name);
|
|
198
232
|
}
|
|
233
|
+
getInvalidationDependency(name) {
|
|
234
|
+
return this.invalidationDependencies.get(name);
|
|
235
|
+
}
|
|
236
|
+
markInvalidateOnDependencyChange(filename) {
|
|
237
|
+
this.invalidateOnDependencyChange.add(filename);
|
|
238
|
+
}
|
|
199
239
|
getResolveTask(name) {
|
|
200
240
|
return this.resolveTasks.get(name);
|
|
201
241
|
}
|
|
@@ -224,8 +264,12 @@ class Entrypoint extends _BaseEntrypoint.BaseEntrypoint {
|
|
|
224
264
|
type: 'setTransformResult'
|
|
225
265
|
});
|
|
226
266
|
}
|
|
267
|
+
deferOnlySupersede(only) {
|
|
268
|
+
this.#pendingOnly = this.#pendingOnly ? (0, _Entrypoint.mergeOnly)(this.#pendingOnly, only) : [...only];
|
|
269
|
+
}
|
|
227
270
|
supersede(newOnlyOrEntrypoint) {
|
|
228
|
-
|
|
271
|
+
this.#pendingOnly = null;
|
|
272
|
+
const newEntrypoint = newOnlyOrEntrypoint instanceof Entrypoint ? newOnlyOrEntrypoint : new Entrypoint(this.services, this.parents, this.initialCode, this.name, newOnlyOrEntrypoint, this.exports, this.evaluatedOnly, this.loadedAndParsed, this.resolveTasks, this.dependencies, this.invalidationDependencies, this.invalidateOnDependencyChange, this.generation + 1);
|
|
229
273
|
this.services.eventEmitter.entrypointEvent(this.seqId, {
|
|
230
274
|
type: 'superseded',
|
|
231
275
|
with: newEntrypoint.seqId
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entrypoint.js","names":["_tsInvariant","require","_BaseEntrypoint","_Entrypoint","_isStaticallyEvaluatableModule","_EvaluatedEntrypoint","_AbortError","_BaseAction","_UnprocessedEntrypointError","EMPTY_FILE","hasLoop","name","parent","processed","includes","p","parents","found","Entrypoint","BaseEntrypoint","evaluated","onSupersedeHandlers","actionsCache","Map","hasWywMetadata","supersededWith","transformResultCode","constructor","services","initialCode","only","exports","evaluatedOnly","loadedAndParsed","resolveTasks","dependencies","generation","_parents$0$log","_parents$","loadAndParseFn","log","code","undefined","cache","invalidateIfChanged","evaluator","originalCode","extend","ignored","_this$supersededWith$","_this$supersededWith","transformedCode","_ref","_this$transformResult","_this$supersededWith2","createRoot","loadedCode","created","create","invariant","eventEmitter","perf","status","entrypoint","innerCreate","seqId","add","_cached$evaluatedOnly","cached","get","changed","mergedOnly","mergeOnly","isLoop","map","push","isSuperSet","supersede","newEntrypoint","ast","isStaticallyEvaluatableModule","length","addDependency","dependency","delete","source","set","addResolveTask","assertNotSuperseded","AbortError","assertTransformed","_this$supersededWith3","UnprocessedEntrypointError","createAction","actionType","data","abortSignal","_cached$abortSignal","has","aborted","newAction","BaseAction","entrypointEvent","type","actionIdx","idx","createChild","createEvaluated","EvaluatedEntrypoint","exportsProxy","getDependency","getResolveTask","onSupersede","callback","index","indexOf","splice","setTransformResult","res","_res$code","Boolean","metadata","isNull","newOnlyOrEntrypoint","with","forEach","handler"],"sources":["../../src/transform/Entrypoint.ts"],"sourcesContent":["import { invariant } from 'ts-invariant';\n\nimport type { ParentEntrypoint, ITransformFileResult } from '../types';\n\nimport { BaseEntrypoint } from './BaseEntrypoint';\nimport { isSuperSet, mergeOnly } from './Entrypoint.helpers';\nimport { isStaticallyEvaluatableModule } from './isStaticallyEvaluatableModule';\nimport type {\n IEntrypointCode,\n IEntrypointDependency,\n IIgnoredEntrypoint,\n} from './Entrypoint.types';\nimport { EvaluatedEntrypoint } from './EvaluatedEntrypoint';\nimport { AbortError } from './actions/AbortError';\nimport type { ActionByType } from './actions/BaseAction';\nimport { BaseAction } from './actions/BaseAction';\nimport { UnprocessedEntrypointError } from './actions/UnprocessedEntrypointError';\nimport type { Services, ActionTypes, ActionQueueItem } from './types';\n\nconst EMPTY_FILE = '=== empty file ===';\n\nfunction hasLoop(\n name: string,\n parent: ParentEntrypoint,\n processed: string[] = []\n): boolean {\n if (parent.name === name || processed.includes(parent.name)) {\n return true;\n }\n\n for (const p of parent.parents) {\n const found = hasLoop(name, p, [...processed, parent.name]);\n if (found) {\n return found;\n }\n }\n\n return false;\n}\n\nexport class Entrypoint extends BaseEntrypoint {\n public readonly evaluated = false;\n\n public readonly loadedAndParsed: IEntrypointCode | IIgnoredEntrypoint;\n\n protected onSupersedeHandlers: Array<(newEntrypoint: Entrypoint) => void> =\n [];\n\n private actionsCache: Map<\n ActionTypes,\n Map<unknown, BaseAction<ActionQueueItem>>\n > = new Map();\n\n #hasWywMetadata: boolean = false;\n\n #supersededWith: Entrypoint | null = null;\n\n #transformResultCode: string | null = null;\n\n private constructor(\n services: Services,\n parents: ParentEntrypoint[],\n public readonly initialCode: string | undefined,\n name: string,\n only: string[],\n exports: Record<string | symbol, unknown> | undefined,\n evaluatedOnly: string[],\n loadedAndParsed?: IEntrypointCode | IIgnoredEntrypoint,\n protected readonly resolveTasks = new Map<\n string,\n Promise<IEntrypointDependency>\n >(),\n readonly dependencies = new Map<string, IEntrypointDependency>(),\n generation = 1\n ) {\n super(\n services,\n evaluatedOnly,\n exports,\n generation,\n name,\n only,\n parents,\n dependencies\n );\n\n this.loadedAndParsed =\n loadedAndParsed ??\n services.loadAndParseFn(\n services,\n name,\n initialCode,\n parents[0]?.log ?? services.log\n );\n\n if (this.loadedAndParsed.code !== undefined) {\n services.cache.invalidateIfChanged(\n name,\n this.loadedAndParsed.code,\n undefined,\n this.initialCode === undefined ? 'fs' : 'loaded'\n );\n }\n\n const code =\n this.loadedAndParsed.evaluator === 'ignored'\n ? '[IGNORED]'\n : this.originalCode || EMPTY_FILE;\n\n this.log.extend('source')('created %s (%o)\\n%s', name, only, code);\n }\n\n public get ignored() {\n return this.loadedAndParsed.evaluator === 'ignored';\n }\n\n public get originalCode() {\n return this.loadedAndParsed.code;\n }\n\n public get supersededWith(): Entrypoint | null {\n return this.#supersededWith?.supersededWith ?? this.#supersededWith;\n }\n\n public get transformedCode(): string | null {\n return (\n this.#transformResultCode ?? this.supersededWith?.transformedCode ?? null\n );\n }\n\n public static createRoot(\n services: Services,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): Entrypoint {\n const created = Entrypoint.create(services, null, name, only, loadedCode);\n invariant(created !== 'loop', 'loop detected');\n\n return created;\n }\n\n /**\n * Creates an entrypoint for the specified file.\n * If there is already an entrypoint for this file, there will be four possible outcomes:\n * 1. If `loadedCode` is specified and is different from the one that was used to create the existing entrypoint,\n * the existing entrypoint will be superseded by a new one and all cached results for it will be invalidated.\n * It can happen if the file was changed and the watcher notified us about it, or we received a new version\n * of the file from a loader whereas the previous one was loaded from the filesystem.\n * The new entrypoint will be returned.\n * 2. If `only` is subset of the existing entrypoint's `only`, the existing entrypoint will be returned.\n * 3. If `only` is superset of the existing entrypoint's `only`, the existing entrypoint will be superseded and the new one will be returned.\n * 4. If a loop is detected, 'ignored' will be returned, the existing entrypoint will be superseded or not depending on the `only` value.\n */\n protected static create(\n services: Services,\n parent: ParentEntrypoint | null,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): Entrypoint | 'loop' {\n const { cache, eventEmitter } = services;\n return eventEmitter.perf('createEntrypoint', () => {\n const [status, entrypoint] = Entrypoint.innerCreate(\n services,\n parent\n ? {\n evaluated: parent.evaluated,\n log: parent.log,\n name: parent.name,\n parents: parent.parents,\n seqId: parent.seqId,\n }\n : null,\n name,\n only,\n loadedCode\n );\n\n if (status !== 'cached') {\n cache.add('entrypoints', name, entrypoint);\n }\n\n return status === 'loop' ? 'loop' : entrypoint;\n });\n }\n\n private static innerCreate(\n services: Services,\n parent: ParentEntrypoint | null,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): ['loop' | 'created' | 'cached', Entrypoint] {\n const { cache } = services;\n\n const cached = cache.get('entrypoints', name);\n const changed =\n loadedCode !== undefined\n ? cache.invalidateIfChanged(name, loadedCode, undefined, 'loaded')\n : false;\n\n if (!cached?.evaluated && cached?.ignored) {\n return ['cached', cached];\n }\n\n const exports = cached?.exports;\n const evaluatedOnly = changed ? [] : cached?.evaluatedOnly ?? [];\n\n const mergedOnly = cached?.only ? mergeOnly(cached.only, only) : [...only];\n\n if (cached?.evaluated) {\n cached.log('is already evaluated with', cached.evaluatedOnly);\n }\n\n if (!changed && cached && !cached.evaluated) {\n const isLoop = parent && hasLoop(name, parent);\n if (isLoop) {\n parent.log('[createEntrypoint] %s is a loop', name);\n }\n\n if (parent && !cached.parents.map((p) => p.name).includes(parent.name)) {\n cached.parents.push(parent);\n }\n\n if (isSuperSet(cached.only, mergedOnly)) {\n cached.log('is cached', name);\n return [isLoop ? 'loop' : 'cached', cached];\n }\n\n cached.log(\n 'is cached, but with different `only` %o (the cached one %o)',\n only,\n cached?.only\n );\n\n return [isLoop ? 'loop' : 'created', cached.supersede(mergedOnly)];\n }\n\n const newEntrypoint = new Entrypoint(\n services,\n parent ? [parent] : [],\n loadedCode,\n name,\n mergedOnly,\n exports,\n evaluatedOnly,\n undefined,\n cached && 'resolveTasks' in cached ? cached.resolveTasks : undefined,\n cached && 'dependencies' in cached ? cached.dependencies : undefined,\n cached ? cached.generation + 1 : 1\n );\n\n if (\n !newEntrypoint.ignored &&\n !newEntrypoint.only.includes('*') &&\n !newEntrypoint.only.includes('__wywPreval') &&\n !newEntrypoint.only.includes('side-effect')\n ) {\n const { ast } = newEntrypoint.loadedAndParsed;\n\n if (ast && isStaticallyEvaluatableModule(ast)) {\n newEntrypoint.log(\n '[entrypoint] promote `only` to \"*\" for statically evaluatable module'\n );\n newEntrypoint.only.length = 0;\n newEntrypoint.only.push('*');\n }\n }\n\n if (cached && !cached.evaluated) {\n cached.log('is cached, but with different code');\n cached.supersede(newEntrypoint);\n }\n\n return ['created', newEntrypoint];\n }\n\n public addDependency(dependency: IEntrypointDependency): void {\n this.resolveTasks.delete(dependency.source);\n this.dependencies.set(dependency.source, dependency);\n }\n\n public addResolveTask(\n name: string,\n dependency: Promise<IEntrypointDependency>\n ): void {\n this.resolveTasks.set(name, dependency);\n }\n\n public assertNotSuperseded() {\n if (this.supersededWith) {\n this.log('superseded');\n throw new AbortError('superseded');\n }\n }\n\n public assertTransformed() {\n if (this.transformedCode === null) {\n this.log('not transformed');\n throw new UnprocessedEntrypointError(this.supersededWith ?? this);\n }\n }\n\n public createAction<\n TType extends ActionTypes,\n TAction extends ActionByType<TType>,\n >(\n actionType: TType,\n data: TAction['data'],\n abortSignal: AbortSignal | null = null\n ): BaseAction<TAction> {\n if (!this.actionsCache.has(actionType)) {\n this.actionsCache.set(actionType, new Map());\n }\n\n const cache = this.actionsCache.get(actionType)!;\n const cached = cache.get(data);\n if (cached && !cached.abortSignal?.aborted) {\n return cached as BaseAction<TAction>;\n }\n\n const newAction = new BaseAction<TAction>(\n actionType as TAction['type'],\n this.services,\n this,\n data,\n abortSignal\n );\n\n cache.set(data, newAction);\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n type: 'actionCreated',\n actionType,\n actionIdx: newAction.idx,\n });\n\n return newAction;\n }\n\n public createChild(\n name: string,\n only: string[],\n loadedCode?: string\n ): Entrypoint | 'loop' {\n return Entrypoint.create(this.services, this, name, only, loadedCode);\n }\n\n public createEvaluated() {\n const evaluatedOnly = mergeOnly(this.evaluatedOnly, this.only);\n this.log('create EvaluatedEntrypoint for %o', evaluatedOnly);\n\n const evaluated = new EvaluatedEntrypoint(\n this.services,\n evaluatedOnly,\n this.exportsProxy,\n this.generation + 1,\n this.name,\n this.only,\n this.parents,\n this.dependencies\n );\n\n evaluated.initialCode = this.initialCode;\n\n return evaluated;\n }\n\n public getDependency(name: string): IEntrypointDependency | undefined {\n return this.dependencies.get(name);\n }\n\n public getResolveTask(\n name: string\n ): Promise<IEntrypointDependency> | undefined {\n return this.resolveTasks.get(name);\n }\n\n public hasWywMetadata() {\n return this.#hasWywMetadata;\n }\n\n public onSupersede(callback: (newEntrypoint: Entrypoint) => void) {\n if (this.#supersededWith) {\n callback(this.#supersededWith);\n return () => {};\n }\n\n this.onSupersedeHandlers.push(callback);\n\n return () => {\n const index = this.onSupersedeHandlers.indexOf(callback);\n if (index >= 0) {\n this.onSupersedeHandlers.splice(index, 1);\n }\n };\n }\n\n public setTransformResult(res: ITransformFileResult | null) {\n this.#hasWywMetadata = Boolean(res?.metadata);\n this.#transformResultCode = res?.code ?? null;\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n isNull: res === null,\n type: 'setTransformResult',\n });\n }\n\n private supersede(newOnlyOrEntrypoint: string[] | Entrypoint): Entrypoint {\n const newEntrypoint =\n newOnlyOrEntrypoint instanceof Entrypoint\n ? newOnlyOrEntrypoint\n : new Entrypoint(\n this.services,\n this.parents,\n this.initialCode,\n this.name,\n newOnlyOrEntrypoint,\n this.exports,\n this.evaluatedOnly,\n this.loadedAndParsed,\n this.resolveTasks,\n this.dependencies,\n this.generation + 1\n );\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n type: 'superseded',\n with: newEntrypoint.seqId,\n });\n this.log(\n 'superseded by %s (%o -> %o)',\n newEntrypoint.name,\n this.only,\n newEntrypoint.only\n );\n this.#supersededWith = newEntrypoint;\n this.onSupersedeHandlers.forEach((handler) => handler(newEntrypoint));\n\n return newEntrypoint;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,8BAAA,GAAAH,OAAA;AAMA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,2BAAA,GAAAP,OAAA;AAGA,MAAMQ,UAAU,GAAG,oBAAoB;AAEvC,SAASC,OAAOA,CACdC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AAC;IAEP,IAAI,CAACR,QAAQ,CAACgC,YAAY,CAAC0C,eAAe,CAAC,IAAI,CAACrC,KAAK,EAAE;MACrDsC,IAAI,EAAE,YAAY;MAClBqB,IAAI,EAAE9C,aAAa,CAACb;IACtB,CAAC,CAAC;IACF,IAAI,CAACzB,GAAG,CACN,6BAA6B,EAC7BsC,aAAa,CAACnE,IAAI,EAClB,IAAI,CAACmB,IAAI,EACTgD,aAAa,CAAChD,IAChB,CAAC;IACD,IAAI,CAAC,CAACL,cAAc,GAAGqD,aAAa;IACpC,IAAI,CAACzD,mBAAmB,CAACwG,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAAChD,aAAa,CAAC,CAAC;IAErE,OAAOA,aAAa;EACtB;AACF;AAAC/C,OAAA,CAAAb,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Entrypoint.js","names":["_nodeFs","_interopRequireDefault","require","_tsInvariant","_BaseEntrypoint","_Entrypoint","_EvaluatedEntrypoint","_AbortError","_BaseAction","_UnprocessedEntrypointError","_parseRequest","e","__esModule","default","EMPTY_FILE","hasLoop","name","parent","processed","includes","p","parents","found","Entrypoint","BaseEntrypoint","evaluated","onSupersedeHandlers","actionsCache","Map","hasWywMetadata","isProcessing","pendingOnly","supersededWith","transformResultCode","constructor","services","initialCode","only","exports","evaluatedOnly","loadedAndParsed","resolveTasks","dependencies","invalidationDependencies","invalidateOnDependencyChange","Set","generation","_parents$0$log","_parents$","loadAndParseFn","log","code","undefined","cache","invalidateIfChanged","evaluator","originalCode","extend","ignored","_this$supersededWith$","_this$supersededWith","transformedCode","_ref","_this$transformResult","_this$supersededWith2","createRoot","loadedCode","created","create","invariant","eventEmitter","perf","status","entrypoint","innerCreate","seqId","add","_cached$evaluatedOnly","cached","get","changed","fs","readFileSync","stripQueryAndHash","mergedOnly","mergeOnly","isLoop","map","push","isSuperSet","deferOnlySupersede","supersede","newEntrypoint","addDependency","dependency","delete","source","set","addInvalidationDependency","addResolveTask","applyDeferredSupersede","nextEntrypoint","assertNotSuperseded","AbortError","assertTransformed","_this$supersededWith3","UnprocessedEntrypointError","beginProcessing","createAction","actionType","data","abortSignal","_cached$abortSignal","has","aborted","newAction","BaseAction","entrypointEvent","type","actionIdx","idx","createChild","createEvaluated","EvaluatedEntrypoint","exportsProxy","endProcessing","getDependency","getInvalidationDependency","markInvalidateOnDependencyChange","filename","getResolveTask","onSupersede","callback","index","indexOf","splice","setTransformResult","res","_res$code","Boolean","metadata","isNull","newOnlyOrEntrypoint","with","forEach","handler"],"sources":["../../src/transform/Entrypoint.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { invariant } from 'ts-invariant';\n\nimport type { ParentEntrypoint, ITransformFileResult } from '../types';\n\nimport { BaseEntrypoint } from './BaseEntrypoint';\nimport { isSuperSet, mergeOnly } from './Entrypoint.helpers';\nimport type {\n IEntrypointCode,\n IEntrypointDependency,\n IIgnoredEntrypoint,\n} from './Entrypoint.types';\nimport { EvaluatedEntrypoint } from './EvaluatedEntrypoint';\nimport { AbortError } from './actions/AbortError';\nimport type { ActionByType } from './actions/BaseAction';\nimport { BaseAction } from './actions/BaseAction';\nimport { UnprocessedEntrypointError } from './actions/UnprocessedEntrypointError';\nimport type { Services, ActionTypes, ActionQueueItem } from './types';\nimport { stripQueryAndHash } from '../utils/parseRequest';\n\nconst EMPTY_FILE = '=== empty file ===';\n\nfunction hasLoop(\n name: string,\n parent: ParentEntrypoint,\n processed: string[] = []\n): boolean {\n if (parent.name === name || processed.includes(parent.name)) {\n return true;\n }\n\n for (const p of parent.parents) {\n const found = hasLoop(name, p, [...processed, parent.name]);\n if (found) {\n return found;\n }\n }\n\n return false;\n}\n\nexport class Entrypoint extends BaseEntrypoint {\n public readonly evaluated = false;\n\n public readonly loadedAndParsed: IEntrypointCode | IIgnoredEntrypoint;\n\n protected onSupersedeHandlers: Array<(newEntrypoint: Entrypoint) => void> =\n [];\n\n private actionsCache: Map<\n ActionTypes,\n Map<unknown, BaseAction<ActionQueueItem>>\n > = new Map();\n\n #hasWywMetadata: boolean = false;\n\n #isProcessing = false;\n\n #pendingOnly: string[] | null = null;\n\n #supersededWith: Entrypoint | null = null;\n\n #transformResultCode: string | null = null;\n\n private constructor(\n services: Services,\n parents: ParentEntrypoint[],\n public readonly initialCode: string | undefined,\n name: string,\n only: string[],\n exports: Record<string | symbol, unknown> | undefined,\n evaluatedOnly: string[],\n loadedAndParsed?: IEntrypointCode | IIgnoredEntrypoint,\n protected readonly resolveTasks = new Map<\n string,\n Promise<IEntrypointDependency>\n >(),\n readonly dependencies = new Map<string, IEntrypointDependency>(),\n readonly invalidationDependencies = new Map<\n string,\n IEntrypointDependency\n >(),\n readonly invalidateOnDependencyChange = new Set<string>(),\n generation = 1\n ) {\n super(\n services,\n evaluatedOnly,\n exports,\n generation,\n name,\n only,\n parents,\n dependencies,\n invalidationDependencies,\n invalidateOnDependencyChange\n );\n\n this.loadedAndParsed =\n loadedAndParsed ??\n services.loadAndParseFn(\n services,\n name,\n initialCode,\n parents[0]?.log ?? services.log\n );\n\n if (this.loadedAndParsed.code !== undefined) {\n services.cache.invalidateIfChanged(\n name,\n this.loadedAndParsed.code,\n undefined,\n this.initialCode === undefined ? 'fs' : 'loaded'\n );\n }\n\n const code =\n this.loadedAndParsed.evaluator === 'ignored'\n ? '[IGNORED]'\n : this.originalCode || EMPTY_FILE;\n\n this.log.extend('source')('created %s (%o)\\n%s', name, only, code);\n }\n\n public get ignored() {\n return this.loadedAndParsed.evaluator === 'ignored';\n }\n\n public get originalCode() {\n return this.loadedAndParsed.code;\n }\n\n public get supersededWith(): Entrypoint | null {\n return this.#supersededWith?.supersededWith ?? this.#supersededWith;\n }\n\n public get transformedCode(): string | null {\n return (\n this.#transformResultCode ?? this.supersededWith?.transformedCode ?? null\n );\n }\n\n public static createRoot(\n services: Services,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): Entrypoint {\n const created = Entrypoint.create(services, null, name, only, loadedCode);\n invariant(created !== 'loop', 'loop detected');\n\n return created;\n }\n\n /**\n * Creates an entrypoint for the specified file.\n * If there is already an entrypoint for this file, there will be four possible outcomes:\n * 1. If `loadedCode` is specified and is different from the one that was used to create the existing entrypoint,\n * the existing entrypoint will be superseded by a new one and all cached results for it will be invalidated.\n * It can happen if the file was changed and the watcher notified us about it, or we received a new version\n * of the file from a loader whereas the previous one was loaded from the filesystem.\n * The new entrypoint will be returned.\n * 2. If `only` is subset of the existing entrypoint's `only`, the existing entrypoint will be returned.\n * 3. If `only` is superset of the existing entrypoint's `only`, the existing entrypoint will be superseded and the new one will be returned.\n * 4. If a loop is detected, 'ignored' will be returned, the existing entrypoint will be superseded or not depending on the `only` value.\n */\n protected static create(\n services: Services,\n parent: ParentEntrypoint | null,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): Entrypoint | 'loop' {\n const { cache, eventEmitter } = services;\n return eventEmitter.perf('createEntrypoint', () => {\n const [status, entrypoint] = Entrypoint.innerCreate(\n services,\n parent\n ? {\n evaluated: parent.evaluated,\n log: parent.log,\n name: parent.name,\n parents: parent.parents,\n seqId: parent.seqId,\n }\n : null,\n name,\n only,\n loadedCode\n );\n\n if (status !== 'cached') {\n cache.add('entrypoints', name, entrypoint);\n }\n\n return status === 'loop' ? 'loop' : entrypoint;\n });\n }\n\n private static innerCreate(\n services: Services,\n parent: ParentEntrypoint | null,\n name: string,\n only: string[],\n loadedCode: string | undefined\n ): ['loop' | 'created' | 'cached', Entrypoint] {\n const { cache } = services;\n\n const cached = cache.get('entrypoints', name);\n let changed = false;\n if (loadedCode !== undefined) {\n changed = cache.invalidateIfChanged(\n name,\n loadedCode,\n undefined,\n 'loaded'\n );\n } else if (cached && cached.initialCode === undefined) {\n try {\n changed = cache.invalidateIfChanged(\n name,\n fs.readFileSync(stripQueryAndHash(name), 'utf8'),\n undefined,\n 'fs'\n );\n } catch {\n changed = false;\n }\n }\n\n if (!cached?.evaluated && cached?.ignored) {\n return ['cached', cached];\n }\n\n const exports = cached?.exports;\n const evaluatedOnly = changed ? [] : cached?.evaluatedOnly ?? [];\n\n const mergedOnly = cached?.only ? mergeOnly(cached.only, only) : [...only];\n\n if (cached?.evaluated) {\n cached.log('is already evaluated with', cached.evaluatedOnly);\n }\n\n if (!changed && cached && !cached.evaluated) {\n const isLoop = parent && hasLoop(name, parent);\n if (isLoop) {\n parent.log('[createEntrypoint] %s is a loop', name);\n }\n\n if (parent && !cached.parents.map((p) => p.name).includes(parent.name)) {\n cached.parents.push(parent);\n }\n\n if (isSuperSet(cached.only, mergedOnly)) {\n cached.log('is cached', name);\n return [isLoop ? 'loop' : 'cached', cached];\n }\n\n cached.log(\n 'is cached, but with different `only` %o (the cached one %o)',\n only,\n cached?.only\n );\n\n if (cached.#isProcessing) {\n cached.deferOnlySupersede(mergedOnly);\n cached.log(\n 'is being processed, defer supersede (%o -> %o)',\n cached.only,\n mergedOnly\n );\n return [isLoop ? 'loop' : 'cached', cached];\n }\n\n return [isLoop ? 'loop' : 'created', cached.supersede(mergedOnly)];\n }\n\n const newEntrypoint = new Entrypoint(\n services,\n parent ? [parent] : [],\n loadedCode,\n name,\n mergedOnly,\n exports,\n evaluatedOnly,\n undefined,\n cached && 'resolveTasks' in cached ? cached.resolveTasks : undefined,\n cached && 'dependencies' in cached ? cached.dependencies : undefined,\n cached && 'invalidationDependencies' in cached\n ? cached.invalidationDependencies\n : undefined,\n cached && 'invalidateOnDependencyChange' in cached\n ? cached.invalidateOnDependencyChange\n : undefined,\n cached ? cached.generation + 1 : 1\n );\n\n if (cached && !cached.evaluated) {\n cached.log('is cached, but with different code');\n cached.supersede(newEntrypoint);\n }\n\n return ['created', newEntrypoint];\n }\n\n public addDependency(dependency: IEntrypointDependency): void {\n this.resolveTasks.delete(dependency.source);\n this.dependencies.set(dependency.source, dependency);\n }\n\n public addInvalidationDependency(dependency: IEntrypointDependency): void {\n this.resolveTasks.delete(dependency.source);\n this.invalidationDependencies.set(dependency.source, dependency);\n }\n\n public addResolveTask(\n name: string,\n dependency: Promise<IEntrypointDependency>\n ): void {\n this.resolveTasks.set(name, dependency);\n }\n\n public applyDeferredSupersede() {\n if (this.#supersededWith || this.#pendingOnly === null) {\n return null;\n }\n\n const mergedOnly = mergeOnly(this.only, this.#pendingOnly);\n this.#pendingOnly = null;\n\n if (isSuperSet(this.only, mergedOnly)) {\n return null;\n }\n\n this.log('apply deferred supersede (%o -> %o)', this.only, mergedOnly);\n\n const nextEntrypoint = this.supersede(mergedOnly);\n this.services.cache.add('entrypoints', this.name, nextEntrypoint);\n\n return nextEntrypoint;\n }\n\n public assertNotSuperseded() {\n if (this.supersededWith) {\n this.log('superseded');\n throw new AbortError('superseded');\n }\n }\n\n public assertTransformed() {\n if (this.transformedCode === null) {\n this.log('not transformed');\n throw new UnprocessedEntrypointError(this.supersededWith ?? this);\n }\n }\n\n public beginProcessing() {\n this.#isProcessing = true;\n }\n\n public createAction<\n TType extends ActionTypes,\n TAction extends ActionByType<TType>,\n >(\n actionType: TType,\n data: TAction['data'],\n abortSignal: AbortSignal | null = null\n ): BaseAction<TAction> {\n if (!this.actionsCache.has(actionType)) {\n this.actionsCache.set(actionType, new Map());\n }\n\n const cache = this.actionsCache.get(actionType)!;\n const cached = cache.get(data);\n if (cached && !cached.abortSignal?.aborted) {\n return cached as BaseAction<TAction>;\n }\n\n const newAction = new BaseAction<TAction>(\n actionType as TAction['type'],\n this.services,\n this,\n data,\n abortSignal\n );\n\n cache.set(data, newAction);\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n type: 'actionCreated',\n actionType,\n actionIdx: newAction.idx,\n });\n\n return newAction;\n }\n\n public createChild(\n name: string,\n only: string[],\n loadedCode?: string\n ): Entrypoint | 'loop' {\n return Entrypoint.create(this.services, this, name, only, loadedCode);\n }\n\n public createEvaluated() {\n const evaluatedOnly = mergeOnly(this.evaluatedOnly, this.only);\n this.log('create EvaluatedEntrypoint for %o', evaluatedOnly);\n\n const evaluated = new EvaluatedEntrypoint(\n this.services,\n evaluatedOnly,\n this.exportsProxy,\n this.generation + 1,\n this.name,\n this.only,\n this.parents,\n this.dependencies,\n this.invalidationDependencies,\n this.invalidateOnDependencyChange\n );\n\n evaluated.initialCode = this.initialCode;\n\n return evaluated;\n }\n\n public endProcessing() {\n this.#isProcessing = false;\n }\n\n public getDependency(name: string): IEntrypointDependency | undefined {\n return this.dependencies.get(name);\n }\n\n public getInvalidationDependency(\n name: string\n ): IEntrypointDependency | undefined {\n return this.invalidationDependencies.get(name);\n }\n\n public markInvalidateOnDependencyChange(filename: string): void {\n this.invalidateOnDependencyChange.add(filename);\n }\n\n public getResolveTask(\n name: string\n ): Promise<IEntrypointDependency> | undefined {\n return this.resolveTasks.get(name);\n }\n\n public hasWywMetadata() {\n return this.#hasWywMetadata;\n }\n\n public onSupersede(callback: (newEntrypoint: Entrypoint) => void) {\n if (this.#supersededWith) {\n callback(this.#supersededWith);\n return () => {};\n }\n\n this.onSupersedeHandlers.push(callback);\n\n return () => {\n const index = this.onSupersedeHandlers.indexOf(callback);\n if (index >= 0) {\n this.onSupersedeHandlers.splice(index, 1);\n }\n };\n }\n\n public setTransformResult(res: ITransformFileResult | null) {\n this.#hasWywMetadata = Boolean(res?.metadata);\n this.#transformResultCode = res?.code ?? null;\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n isNull: res === null,\n type: 'setTransformResult',\n });\n }\n\n private deferOnlySupersede(only: string[]) {\n this.#pendingOnly = this.#pendingOnly\n ? mergeOnly(this.#pendingOnly, only)\n : [...only];\n }\n\n private supersede(newOnlyOrEntrypoint: string[] | Entrypoint): Entrypoint {\n this.#pendingOnly = null;\n const newEntrypoint =\n newOnlyOrEntrypoint instanceof Entrypoint\n ? newOnlyOrEntrypoint\n : new Entrypoint(\n this.services,\n this.parents,\n this.initialCode,\n this.name,\n newOnlyOrEntrypoint,\n this.exports,\n this.evaluatedOnly,\n this.loadedAndParsed,\n this.resolveTasks,\n this.dependencies,\n this.invalidationDependencies,\n this.invalidateOnDependencyChange,\n this.generation + 1\n );\n\n this.services.eventEmitter.entrypointEvent(this.seqId, {\n type: 'superseded',\n with: newEntrypoint.seqId,\n });\n this.log(\n 'superseded by %s (%o -> %o)',\n newEntrypoint.name,\n this.only,\n newEntrypoint.only\n );\n this.#supersededWith = newEntrypoint;\n this.onSupersedeHandlers.forEach((handler) => handler(newEntrypoint));\n\n return newEntrypoint;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAEA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,2BAAA,GAAAP,OAAA;AAEA,IAAAQ,aAAA,GAAAR,OAAA;AAA0D,SAAAD,uBAAAU,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1D,MAAMG,UAAU,GAAG,oBAAoB;AAEvC,SAASC,OAAOA,CACdC,IAAY,EACZC,MAAwB,EACxBC,SAAmB,GAAG,EAAE,EACf;EACT,IAAID,MAAM,CAACD,IAAI,KAAKA,IAAI,IAAIE,SAAS,CAACC,QAAQ,CAACF,MAAM,CAACD,IAAI,CAAC,EAAE;IAC3D,OAAO,IAAI;EACb;EAEA,KAAK,MAAMI,CAAC,IAAIH,MAAM,CAACI,OAAO,EAAE;IAC9B,MAAMC,KAAK,GAAGP,OAAO,CAACC,IAAI,EAAEI,CAAC,EAAE,CAAC,GAAGF,SAAS,EAAED,MAAM,CAACD,IAAI,CAAC,CAAC;IAC3D,IAAIM,KAAK,EAAE;MACT,OAAOA,KAAK;IACd;EACF;EAEA,OAAO,KAAK;AACd;AAEO,MAAMC,UAAU,SAASC,8BAAc,CAAC;EAC7BC,SAAS,GAAG,KAAK;EAIvBC,mBAAmB,GAC3B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IvH,UAAU,CACZ,IAAI,CAACY,QAAQ,EACb,IAAI,CAACd,OAAO,EACZ,IAAI,CAACe,WAAW,EAChB,IAAI,CAACpB,IAAI,EACT8H,mBAAmB,EACnB,IAAI,CAACxG,OAAO,EACZ,IAAI,CAACC,aAAa,EAClB,IAAI,CAACC,eAAe,EACpB,IAAI,CAACC,YAAY,EACjB,IAAI,CAACC,YAAY,EACjB,IAAI,CAACC,wBAAwB,EAC7B,IAAI,CAACC,4BAA4B,EACjC,IAAI,CAACE,UAAU,GAAG,CACpB,CAAC;IAEP,IAAI,CAACX,QAAQ,CAACmC,YAAY,CAAC+C,eAAe,CAAC,IAAI,CAAC1C,KAAK,EAAE;MACrD2C,IAAI,EAAE,YAAY;MAClByB,IAAI,EAAEnD,aAAa,CAACjB;IACtB,CAAC,CAAC;IACF,IAAI,CAACzB,GAAG,CACN,6BAA6B,EAC7B0C,aAAa,CAAC5E,IAAI,EAClB,IAAI,CAACqB,IAAI,EACTuD,aAAa,CAACvD,IAChB,CAAC;IACD,IAAI,CAAC,CAACL,cAAc,GAAG4D,aAAa;IACpC,IAAI,CAAClE,mBAAmB,CAACsH,OAAO,CAAEC,OAAO,IAAKA,OAAO,CAACrD,aAAa,CAAC,CAAC;IAErE,OAAOA,aAAa;EACtB;AACF;AAACtD,OAAA,CAAAf,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EvaluatedEntrypoint.js","names":["_BaseEntrypoint","require","EvaluatedEntrypoint","BaseEntrypoint","evaluated","ignored","exports"],"sources":["../../src/transform/EvaluatedEntrypoint.ts"],"sourcesContent":["import type { Debugger } from '@wyw-in-js/shared';\n\nimport { BaseEntrypoint } from './BaseEntrypoint';\nimport type { IEntrypointDependency } from './Entrypoint.types';\n\nexport interface IEvaluatedEntrypoint {\n dependencies: Map<string, IEntrypointDependency>;\n evaluated: true;\n evaluatedOnly: string[];\n exports: Record<string | symbol, unknown>;\n generation: number;\n ignored: false;\n initialCode?: string;\n log: Debugger;\n only: string[];\n}\n\nexport class EvaluatedEntrypoint\n extends BaseEntrypoint\n implements IEvaluatedEntrypoint\n{\n public readonly evaluated = true;\n\n public readonly ignored = false;\n\n public initialCode?: string;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"EvaluatedEntrypoint.js","names":["_BaseEntrypoint","require","EvaluatedEntrypoint","BaseEntrypoint","evaluated","ignored","exports"],"sources":["../../src/transform/EvaluatedEntrypoint.ts"],"sourcesContent":["import type { Debugger } from '@wyw-in-js/shared';\n\nimport { BaseEntrypoint } from './BaseEntrypoint';\nimport type { IEntrypointDependency } from './Entrypoint.types';\n\nexport interface IEvaluatedEntrypoint {\n dependencies: Map<string, IEntrypointDependency>;\n evaluated: true;\n evaluatedOnly: string[];\n exports: Record<string | symbol, unknown>;\n generation: number;\n ignored: false;\n initialCode?: string;\n invalidationDependencies: Map<string, IEntrypointDependency>;\n invalidateOnDependencyChange: Set<string>;\n log: Debugger;\n only: string[];\n}\n\nexport class EvaluatedEntrypoint\n extends BaseEntrypoint\n implements IEvaluatedEntrypoint\n{\n public readonly evaluated = true;\n\n public readonly ignored = false;\n\n public initialCode?: string;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AAiBO,MAAMC,mBAAmB,SACtBC,8BAAc,CAExB;EACkBC,SAAS,GAAG,IAAI;EAEhBC,OAAO,GAAG,KAAK;AAGjC;AAACC,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.analyzeBarrelFile = analyzeBarrelFile;
|
|
7
|
+
var _traverse = _interopRequireDefault(require("@babel/traverse"));
|
|
8
|
+
var _types = require("@babel/types");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
/* eslint-disable no-continue, @typescript-eslint/no-use-before-define */
|
|
11
|
+
|
|
12
|
+
const isTypeOnlyImport = statement => {
|
|
13
|
+
if (statement.importKind === 'type') {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (statement.specifiers.length === 0) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return statement.specifiers.every(specifier => specifier.type === 'ImportSpecifier' && specifier.importKind === 'type');
|
|
20
|
+
};
|
|
21
|
+
const isTypeOnlyExport = statement => statement.exportKind === 'type';
|
|
22
|
+
const getModuleExportName = node => node.type === 'Identifier' ? node.name : node.value;
|
|
23
|
+
const isTypeOnlyStatement = statement => {
|
|
24
|
+
switch (statement.type) {
|
|
25
|
+
case 'EmptyStatement':
|
|
26
|
+
case 'TSDeclareFunction':
|
|
27
|
+
case 'TSInterfaceDeclaration':
|
|
28
|
+
case 'TSTypeAliasDeclaration':
|
|
29
|
+
return true;
|
|
30
|
+
default:
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
function collectExportNamedDeclaration(statement, reexports, explicitExports) {
|
|
35
|
+
if (!statement.source) {
|
|
36
|
+
return isTypeOnlyExport(statement);
|
|
37
|
+
}
|
|
38
|
+
if (isTypeOnlyExport(statement)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
const source = statement.source.value;
|
|
42
|
+
for (const specifier of statement.specifiers) {
|
|
43
|
+
if (specifier.type === 'ExportSpecifier') {
|
|
44
|
+
if (specifier.exportKind === 'type') {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
48
|
+
reexports.push(getNamedReexport(specifier, source));
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (specifier.type === 'ExportDefaultSpecifier') {
|
|
52
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
53
|
+
reexports.push(getDefaultReexport(specifier, source));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (specifier.type === 'ExportNamespaceSpecifier') {
|
|
57
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
58
|
+
reexports.push(getNamespaceReexport(specifier, source));
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return statement.specifiers.length > 0;
|
|
64
|
+
}
|
|
65
|
+
function getNamedReexport(specifier, source) {
|
|
66
|
+
return {
|
|
67
|
+
exported: getModuleExportName(specifier.exported),
|
|
68
|
+
imported: getModuleExportName(specifier.local),
|
|
69
|
+
kind: 'named',
|
|
70
|
+
source
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function getDefaultReexport(specifier, source) {
|
|
74
|
+
return {
|
|
75
|
+
exported: getModuleExportName(specifier.exported),
|
|
76
|
+
imported: 'default',
|
|
77
|
+
kind: 'named',
|
|
78
|
+
source
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function getNamespaceReexport(specifier, source) {
|
|
82
|
+
return {
|
|
83
|
+
exported: getModuleExportName(specifier.exported),
|
|
84
|
+
kind: 'namespace',
|
|
85
|
+
source
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const collectImportBinding = (statement, imports) => {
|
|
89
|
+
if (statement.importKind === 'type') {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (statement.specifiers.length === 0) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
let sawValueImport = false;
|
|
96
|
+
for (const specifier of statement.specifiers) {
|
|
97
|
+
if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
sawValueImport = true;
|
|
101
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
102
|
+
imports.set(specifier.local.name, {
|
|
103
|
+
imported: getImportSpecifierName(specifier),
|
|
104
|
+
kind: 'named',
|
|
105
|
+
source: statement.source.value
|
|
106
|
+
});
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
110
|
+
imports.set(specifier.local.name, {
|
|
111
|
+
imported: 'default',
|
|
112
|
+
kind: 'named',
|
|
113
|
+
source: statement.source.value
|
|
114
|
+
});
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
imports.set(specifier.local.name, {
|
|
118
|
+
kind: 'namespace',
|
|
119
|
+
source: statement.source.value
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return sawValueImport || isTypeOnlyImport(statement);
|
|
123
|
+
};
|
|
124
|
+
const getImportSpecifierName = specifier => getModuleExportName(specifier.imported);
|
|
125
|
+
const getLocalDeclarationNames = declaration => {
|
|
126
|
+
if (declaration.type === 'VariableDeclaration' || declaration.type === 'FunctionDeclaration' || declaration.type === 'ClassDeclaration') {
|
|
127
|
+
return Object.keys((0, _types.getBindingIdentifiers)(declaration));
|
|
128
|
+
}
|
|
129
|
+
if (declaration.type === 'TSEnumDeclaration' || declaration.type === 'TSModuleDeclaration') {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return [];
|
|
133
|
+
};
|
|
134
|
+
const collectLocalExportNamedDeclaration = (statement, importedBindings, passthroughCandidates, explicitExports) => {
|
|
135
|
+
let complete = true;
|
|
136
|
+
if (isTypeOnlyExport(statement)) {
|
|
137
|
+
return {
|
|
138
|
+
complete: true,
|
|
139
|
+
ok: true
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (statement.declaration) {
|
|
143
|
+
const names = getLocalDeclarationNames(statement.declaration);
|
|
144
|
+
if (names === null) {
|
|
145
|
+
return {
|
|
146
|
+
complete: false,
|
|
147
|
+
ok: false
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
for (const name of names) {
|
|
151
|
+
explicitExports.add(name);
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
complete: names.length === 0,
|
|
155
|
+
ok: true
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
for (const specifier of statement.specifiers) {
|
|
159
|
+
if (specifier.type !== 'ExportSpecifier') {
|
|
160
|
+
return {
|
|
161
|
+
complete: false,
|
|
162
|
+
ok: false
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
if (specifier.exportKind === 'type') {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const exported = getModuleExportName(specifier.exported);
|
|
169
|
+
explicitExports.add(exported);
|
|
170
|
+
if (specifier.local.type !== 'Identifier') {
|
|
171
|
+
complete = false;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (!importedBindings.has(specifier.local.name)) {
|
|
175
|
+
complete = false;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!passthroughCandidates.has(specifier.local.name)) {
|
|
179
|
+
passthroughCandidates.set(specifier.local.name, []);
|
|
180
|
+
}
|
|
181
|
+
passthroughCandidates.get(specifier.local.name).push(exported);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
complete: complete && statement.specifiers.length > 0,
|
|
185
|
+
ok: true
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
const collectPassthroughReexports = (ast, importedBindings, passthroughCandidates, reexports) => {
|
|
189
|
+
let complete = true;
|
|
190
|
+
const bindingReferenceCounts = new Map();
|
|
191
|
+
(0, _traverse.default)(ast, {
|
|
192
|
+
Program(path) {
|
|
193
|
+
for (const localName of passthroughCandidates.keys()) {
|
|
194
|
+
var _path$scope$getBindin, _path$scope$getBindin2;
|
|
195
|
+
bindingReferenceCounts.set(localName, (_path$scope$getBindin = (_path$scope$getBindin2 = path.scope.getBinding(localName)) === null || _path$scope$getBindin2 === void 0 ? void 0 : _path$scope$getBindin2.referencePaths.length) !== null && _path$scope$getBindin !== void 0 ? _path$scope$getBindin : -1);
|
|
196
|
+
}
|
|
197
|
+
path.stop();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
for (const [localName, exportedNames] of passthroughCandidates) {
|
|
201
|
+
if (bindingReferenceCounts.get(localName) !== exportedNames.length) {
|
|
202
|
+
complete = false;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const imported = importedBindings.get(localName);
|
|
206
|
+
for (const exported of exportedNames) {
|
|
207
|
+
if (imported.kind === 'namespace') {
|
|
208
|
+
reexports.push({
|
|
209
|
+
exported,
|
|
210
|
+
kind: 'namespace',
|
|
211
|
+
source: imported.source
|
|
212
|
+
});
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
reexports.push({
|
|
216
|
+
exported,
|
|
217
|
+
imported: imported.imported,
|
|
218
|
+
kind: 'named',
|
|
219
|
+
source: imported.source
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
complete,
|
|
225
|
+
ok: true
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
function analyzeBarrelProgram(ast) {
|
|
229
|
+
const reexports = [];
|
|
230
|
+
const explicitExports = new Set();
|
|
231
|
+
const exportAll = [];
|
|
232
|
+
const importedBindings = new Map();
|
|
233
|
+
const passthroughCandidates = new Map();
|
|
234
|
+
let complete = true;
|
|
235
|
+
for (const statement of ast.program.body) {
|
|
236
|
+
if (statement.type === 'ImportDeclaration') {
|
|
237
|
+
if (!collectImportBinding(statement, importedBindings)) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (statement.type === 'ExportNamedDeclaration') {
|
|
243
|
+
if (statement.source) {
|
|
244
|
+
if (!collectExportNamedDeclaration(statement, reexports, explicitExports)) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
const localResult = collectLocalExportNamedDeclaration(statement, importedBindings, passthroughCandidates, explicitExports);
|
|
250
|
+
if (!localResult.ok) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
complete = complete && localResult.complete;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (statement.type === 'ExportAllDeclaration') {
|
|
257
|
+
if (statement.exportKind === 'type') {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (!statement.source) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
exportAll.push(getExportAllSource(statement));
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (statement.type === 'ExportDefaultDeclaration') {
|
|
267
|
+
return null;
|
|
268
|
+
}
|
|
269
|
+
if (!isTypeOnlyStatement(statement)) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const passthroughResult = collectPassthroughReexports(ast, importedBindings, passthroughCandidates, reexports);
|
|
274
|
+
if (!passthroughResult.ok) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
complete = complete && passthroughResult.complete;
|
|
278
|
+
if (reexports.length === 0 && exportAll.length === 0) {
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
complete,
|
|
283
|
+
explicitExports: [...explicitExports],
|
|
284
|
+
exportAll,
|
|
285
|
+
kind: 'barrel',
|
|
286
|
+
reexports
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const getExportAllSource = statement => statement.source.value;
|
|
290
|
+
function analyzeBarrelFile(ast) {
|
|
291
|
+
const result = analyzeBarrelProgram(ast);
|
|
292
|
+
if (!result) {
|
|
293
|
+
return {
|
|
294
|
+
kind: 'ineligible',
|
|
295
|
+
reason: 'impure'
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=barrelManifest.js.map
|