@wyw-in-js/transform 1.0.7 → 1.0.8

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.
Files changed (47) hide show
  1. package/esm/cache.js +60 -5
  2. package/esm/cache.js.map +1 -1
  3. package/esm/module.js +8 -3
  4. package/esm/module.js.map +1 -1
  5. package/esm/transform/Entrypoint.js +8 -3
  6. package/esm/transform/Entrypoint.js.map +1 -1
  7. package/esm/transform/actions/BaseAction.js +2 -1
  8. package/esm/transform/actions/BaseAction.js.map +1 -1
  9. package/esm/transform/actions/actionRunner.js +2 -2
  10. package/esm/transform/actions/actionRunner.js.map +1 -1
  11. package/esm/transform/generators/processEntrypoint.js +5 -1
  12. package/esm/transform/generators/processEntrypoint.js.map +1 -1
  13. package/esm/transform/types.js.map +1 -1
  14. package/esm/transform.js +45 -23
  15. package/esm/transform.js.map +1 -1
  16. package/esm/utils/collectTemplateDependencies.js +9 -0
  17. package/esm/utils/collectTemplateDependencies.js.map +1 -1
  18. package/lib/cache.js +60 -5
  19. package/lib/cache.js.map +1 -1
  20. package/lib/module.js +10 -5
  21. package/lib/module.js.map +1 -1
  22. package/lib/transform/Entrypoint.js +8 -3
  23. package/lib/transform/Entrypoint.js.map +1 -1
  24. package/lib/transform/actions/BaseAction.js +2 -1
  25. package/lib/transform/actions/BaseAction.js.map +1 -1
  26. package/lib/transform/actions/actionRunner.js +2 -2
  27. package/lib/transform/actions/actionRunner.js.map +1 -1
  28. package/lib/transform/generators/processEntrypoint.js +5 -1
  29. package/lib/transform/generators/processEntrypoint.js.map +1 -1
  30. package/lib/transform/types.js.map +1 -1
  31. package/lib/transform.js +45 -23
  32. package/lib/transform.js.map +1 -1
  33. package/lib/utils/collectTemplateDependencies.js +9 -0
  34. package/lib/utils/collectTemplateDependencies.js.map +1 -1
  35. package/package.json +1 -1
  36. package/types/cache.d.ts +7 -0
  37. package/types/cache.js +59 -3
  38. package/types/module.js +8 -3
  39. package/types/transform/Entrypoint.d.ts +1 -1
  40. package/types/transform/Entrypoint.js +8 -3
  41. package/types/transform/actions/BaseAction.d.ts +2 -1
  42. package/types/transform/actions/BaseAction.js +3 -1
  43. package/types/transform/actions/actionRunner.js +2 -2
  44. package/types/transform/generators/processEntrypoint.js +4 -1
  45. package/types/transform/types.d.ts +1 -0
  46. package/types/transform.js +47 -23
  47. package/types/utils/collectTemplateDependencies.js +9 -0
package/esm/cache.js CHANGED
@@ -6,6 +6,15 @@ import { stripQueryAndHash } from './utils/parseRequest';
6
6
  function hashContent(content) {
7
7
  return createHash('sha256').update(content).digest('hex');
8
8
  }
9
+ function isMissingFileError(error) {
10
+ if (!error || typeof error !== 'object') {
11
+ return false;
12
+ }
13
+ const {
14
+ code
15
+ } = error;
16
+ return code === 'ENOENT' || code === 'ENOTDIR';
17
+ }
9
18
  const cacheLogger = logger.extend('cache');
10
19
  const cacheNames = ['barrelManifests', 'entrypoints', 'exports'];
11
20
  const loggers = cacheNames.reduce((acc, key) => ({
@@ -15,6 +24,7 @@ const loggers = cacheNames.reduce((acc, key) => ({
15
24
  export class TransformCacheCollection {
16
25
  barrelManifestDependencies = new Map();
17
26
  contentHashes = new Map();
27
+ fileMtimes = new Map();
18
28
  exportDependencies = new Map();
19
29
  constructor(caches = {}) {
20
30
  this.barrelManifests = caches.barrelManifests || new Map();
@@ -144,7 +154,18 @@ export class TransformCacheCollection {
144
154
  for (const [, dependency] of dependenciesToCheck) {
145
155
  const dependencyFilename = dependency.resolved;
146
156
  if (dependencyFilename) {
147
- const dependencyContent = fs.readFileSync(stripQueryAndHash(dependencyFilename), 'utf8');
157
+ let dependencyContent;
158
+ try {
159
+ dependencyContent = fs.readFileSync(stripQueryAndHash(dependencyFilename), 'utf8');
160
+ } catch (error) {
161
+ if (!isMissingFileError(error)) {
162
+ throw error;
163
+ }
164
+ this.invalidateForFile(dependencyFilename);
165
+ anyDepChanged = true;
166
+ // eslint-disable-next-line no-continue
167
+ continue;
168
+ }
148
169
  const dependencyChanged = this.invalidateIfChanged(dependencyFilename, dependencyContent, visitedFiles, 'fs', changedFiles);
149
170
  if (dependencyChanged && invalidateOnDependencyChange?.has(dependencyFilename)) {
150
171
  cacheLogger('dependency affecting output has changed, invalidate all for %s', filename);
@@ -228,15 +249,49 @@ export class TransformCacheCollection {
228
249
  hasCachedDependencies(filename) {
229
250
  return this.getCachedDependencies(filename).size > 0;
230
251
  }
252
+
253
+ /**
254
+ * Fast check if a file changed on disk since last seen.
255
+ * Uses mtime as a fast path — only reads the file if mtime differs.
256
+ * Returns true if the file changed (cache was invalidated).
257
+ */
258
+ checkFreshness(filename, strippedFilename) {
259
+ try {
260
+ const currentMtime = fs.statSync(strippedFilename).mtimeMs;
261
+ const cachedMtime = this.fileMtimes.get(filename);
262
+ if (cachedMtime !== undefined && currentMtime === cachedMtime) {
263
+ return false;
264
+ }
265
+ const content = fs.readFileSync(strippedFilename, 'utf-8');
266
+ this.fileMtimes.set(filename, currentMtime);
267
+ if (this.invalidateIfChanged(filename, content, undefined, 'fs')) {
268
+ return true;
269
+ }
270
+ return false;
271
+ } catch (error) {
272
+ if (!isMissingFileError(error)) {
273
+ throw error;
274
+ }
275
+ this.invalidateForFile(filename);
276
+ return true;
277
+ }
278
+ }
231
279
  setContentHash(filename, source, hash) {
232
280
  const current = this.contentHashes.get(filename);
233
281
  if (current) {
234
282
  current[source] = hash;
235
- return;
283
+ } else {
284
+ this.contentHashes.set(filename, {
285
+ [source]: hash
286
+ });
287
+ }
288
+ if (source === 'fs') {
289
+ try {
290
+ this.fileMtimes.set(filename, fs.statSync(stripQueryAndHash(filename)).mtimeMs);
291
+ } catch {
292
+ // ignore
293
+ }
236
294
  }
237
- this.contentHashes.set(filename, {
238
- [source]: hash
239
- });
240
295
  }
241
296
  }
242
297
  //# sourceMappingURL=cache.js.map
package/esm/cache.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","names":["createHash","fs","logger","getFileIdx","stripQueryAndHash","hashContent","content","update","digest","cacheLogger","extend","cacheNames","loggers","reduce","acc","key","TransformCacheCollection","barrelManifestDependencies","Map","contentHashes","exportDependencies","constructor","caches","barrelManifests","entrypoints","exports","add","cacheName","value","cache","undefined","has","get","delete","clearCacheDependencies","set","maybeOriginalCode","originalCode","isLoaded","initialCode","source","resolvedCode","setContentHash","fileContent","readFileSync","clear","forEach","name","invalidate","res","invalidateForFile","filename","invalidateIfChanged","previousVisitedFiles","changedFiles","Set","visitedFiles","fileEntrypoint","anyDepChanged","hasCachedDependencies","invalidateOnDependencyChange","dependenciesToCheck","dependency","dependencies","invalidationDependencies","dependencyFilename","getCachedDependencies","values","some","resolved","dependencyContent","dependencyChanged","existing","previousHash","newHash","otherSource","otherHash","setCacheDependencies","getDependencyCache","nextDependencies","filter","length","size","hash","current"],"sources":["../src/cache.ts"],"sourcesContent":["import { createHash } from 'crypto';\nimport fs from 'node:fs';\nimport { logger } from '@wyw-in-js/shared';\n\nimport type { BarrelManifestCacheEntry } from './transform/barrelManifest';\nimport type { Entrypoint } from './transform/Entrypoint';\nimport type { IEvaluatedEntrypoint } from './transform/EvaluatedEntrypoint';\nimport { getFileIdx } from './utils/getFileIdx';\nimport { stripQueryAndHash } from './utils/parseRequest';\n\nfunction hashContent(content: string) {\n return createHash('sha256').update(content).digest('hex');\n}\n\ninterface IBaseCachedEntrypoint {\n dependencies: Map<string, { resolved: string | null }>;\n initialCode?: string;\n invalidateOnDependencyChange?: Set<string>;\n invalidationDependencies?: Map<string, { resolved: string | null }>;\n}\n\ninterface ICaches<TEntrypoint extends IBaseCachedEntrypoint> {\n barrelManifests: Map<string, BarrelManifestCacheEntry>;\n entrypoints: Map<string, TEntrypoint>;\n exports: Map<string, string[]>;\n}\n\ntype MapValue<T> = T extends Map<string, infer V> ? V : never;\n\nconst cacheLogger = logger.extend('cache');\n\nconst cacheNames = ['barrelManifests', 'entrypoints', 'exports'] as const;\ntype CacheNames = (typeof cacheNames)[number];\n\nconst loggers = cacheNames.reduce(\n (acc, key) => ({\n ...acc,\n [key]: cacheLogger.extend(key),\n }),\n {} as Record<CacheNames, typeof logger>\n);\n\nexport class TransformCacheCollection<\n TEntrypoint extends IBaseCachedEntrypoint = Entrypoint | IEvaluatedEntrypoint,\n> {\n public readonly barrelManifests: Map<string, BarrelManifestCacheEntry>;\n\n public readonly entrypoints: Map<string, TEntrypoint>;\n\n public readonly exports: Map<string, string[]>;\n\n private readonly barrelManifestDependencies = new Map<string, Set<string>>();\n\n private contentHashes = new Map<string, { fs?: string; loaded?: string }>();\n\n private readonly exportDependencies = new Map<string, Set<string>>();\n\n constructor(caches: Partial<ICaches<TEntrypoint>> = {}) {\n this.barrelManifests = caches.barrelManifests || new Map();\n this.entrypoints = caches.entrypoints || new Map();\n this.exports = caches.exports || new Map();\n }\n\n public add<\n TCache extends CacheNames,\n TValue extends MapValue<ICaches<TEntrypoint>[TCache]>,\n >(cacheName: TCache, key: string, value: TValue): void {\n const cache = this[cacheName] as Map<string, TValue>;\n loggers[cacheName]('%s:add %s %f', getFileIdx(key), key, () => {\n if (value === undefined) {\n return cache.has(key) ? 'removed' : 'noop';\n }\n\n if (!cache.has(key)) {\n return 'added';\n }\n\n return cache.get(key) === value ? 'unchanged' : 'updated';\n });\n\n if (value === undefined) {\n cache.delete(key);\n this.contentHashes.delete(key);\n this.clearCacheDependencies(cacheName, key);\n return;\n }\n\n this.clearCacheDependencies(cacheName, key);\n cache.set(key, value);\n\n if ('initialCode' in value) {\n const maybeOriginalCode = (value as unknown as { originalCode?: unknown })\n .originalCode;\n const isLoaded = typeof value.initialCode === 'string';\n const source = isLoaded ? 'loaded' : 'fs';\n\n let resolvedCode: string | undefined;\n if (isLoaded) {\n resolvedCode = value.initialCode;\n } else if (typeof maybeOriginalCode === 'string') {\n resolvedCode = maybeOriginalCode;\n }\n\n if (resolvedCode !== undefined) {\n this.setContentHash(key, source, hashContent(resolvedCode));\n return;\n }\n\n try {\n const fileContent = fs.readFileSync(stripQueryAndHash(key), 'utf8');\n this.setContentHash(key, source, hashContent(fileContent));\n } catch {\n this.setContentHash(key, source, hashContent(''));\n }\n\n return;\n }\n\n if (cacheName === 'barrelManifests') {\n try {\n const fileContent = fs.readFileSync(stripQueryAndHash(key), 'utf8');\n this.setContentHash(key, 'fs', hashContent(fileContent));\n } catch {\n this.setContentHash(key, 'fs', hashContent(''));\n }\n }\n }\n\n public clear(cacheName: CacheNames | 'all'): void {\n if (cacheName === 'all') {\n cacheNames.forEach((name) => {\n this.clear(name);\n });\n\n return;\n }\n\n loggers[cacheName]('clear');\n const cache = this[cacheName] as Map<string, unknown>;\n\n cache.clear();\n this.clearCacheDependencies(cacheName);\n }\n\n public delete(cacheName: CacheNames, key: string): void {\n this.invalidate(cacheName, key);\n }\n\n public get<\n TCache extends CacheNames,\n TValue extends MapValue<ICaches<TEntrypoint>[TCache]>,\n >(cacheName: TCache, key: string): TValue | undefined {\n const cache = this[cacheName] as Map<string, TValue>;\n\n const res = cache.get(key);\n loggers[cacheName]('get', key, res === undefined ? 'miss' : 'hit');\n return res;\n }\n\n public has(cacheName: CacheNames, key: string): boolean {\n const cache = this[cacheName] as Map<string, unknown>;\n\n const res = cache.has(key);\n loggers[cacheName]('has', key, res);\n return res;\n }\n\n public invalidate(cacheName: CacheNames, key: string): void {\n const cache = this[cacheName] as Map<string, unknown>;\n if (!cache.has(key)) {\n return;\n }\n\n loggers[cacheName]('invalidate', key);\n\n cache.delete(key);\n this.clearCacheDependencies(cacheName, key);\n }\n\n public invalidateForFile(filename: string) {\n cacheNames.forEach((cacheName) => {\n this.invalidate(cacheName, filename);\n });\n }\n\n public invalidateIfChanged(\n filename: string,\n content: string,\n previousVisitedFiles?: Set<string>,\n source: 'fs' | 'loaded' = 'loaded',\n changedFiles = new Set<string>()\n ) {\n if (changedFiles.has(filename)) {\n return true;\n }\n\n const visitedFiles = new Set(previousVisitedFiles);\n const fileEntrypoint = this.get('entrypoints', filename);\n let anyDepChanged = false;\n\n // We need to check all dependencies of the file\n // because they might have changed as well.\n if (\n !visitedFiles.has(filename) &&\n (fileEntrypoint || this.hasCachedDependencies(filename))\n ) {\n visitedFiles.add(filename);\n const invalidateOnDependencyChange =\n fileEntrypoint?.invalidateOnDependencyChange;\n\n const dependenciesToCheck = new Map<\n string,\n { resolved: string | null }\n >();\n\n for (const [key, dependency] of fileEntrypoint?.dependencies ?? []) {\n dependenciesToCheck.set(key, dependency);\n }\n\n for (const [\n key,\n dependency,\n ] of fileEntrypoint?.invalidationDependencies ?? []) {\n if (!dependenciesToCheck.has(key)) {\n dependenciesToCheck.set(key, dependency);\n }\n }\n\n for (const dependencyFilename of this.getCachedDependencies(filename)) {\n if (\n ![...dependenciesToCheck.values()].some(\n (dependency) => dependency.resolved === dependencyFilename\n )\n ) {\n dependenciesToCheck.set(dependencyFilename, {\n resolved: dependencyFilename,\n });\n }\n }\n\n for (const [, dependency] of dependenciesToCheck) {\n const dependencyFilename = dependency.resolved;\n\n if (dependencyFilename) {\n const dependencyContent = fs.readFileSync(\n stripQueryAndHash(dependencyFilename),\n 'utf8'\n );\n const dependencyChanged = this.invalidateIfChanged(\n dependencyFilename,\n dependencyContent,\n visitedFiles,\n 'fs',\n changedFiles\n );\n\n if (\n dependencyChanged &&\n invalidateOnDependencyChange?.has(dependencyFilename)\n ) {\n cacheLogger(\n 'dependency affecting output has changed, invalidate all for %s',\n filename\n );\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n if (dependencyChanged) {\n anyDepChanged = true;\n }\n }\n }\n }\n\n const existing = this.contentHashes.get(filename);\n const previousHash = existing?.[source];\n const newHash = hashContent(content);\n\n if (previousHash === undefined) {\n const otherSource = source === 'fs' ? 'loaded' : 'fs';\n const otherHash = existing?.[otherSource];\n\n if ((otherHash !== undefined && otherHash !== newHash) || anyDepChanged) {\n cacheLogger('content has changed, invalidate all for %s', filename);\n this.setContentHash(filename, source, newHash);\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n this.setContentHash(filename, source, newHash);\n if (anyDepChanged) {\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n return true;\n }\n return false;\n }\n\n if (previousHash !== newHash || anyDepChanged) {\n cacheLogger('content has changed, invalidate all for %s', filename);\n this.setContentHash(filename, source, newHash);\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n return false;\n }\n\n public setCacheDependencies(\n cacheName: 'barrelManifests' | 'exports',\n key: string,\n dependencies: Iterable<string>\n ): void {\n const cache = this.getDependencyCache(cacheName);\n const nextDependencies = new Set(\n [...dependencies].filter((dependency) => dependency.length > 0)\n );\n\n if (nextDependencies.size === 0) {\n cache.delete(key);\n return;\n }\n\n cache.set(key, nextDependencies);\n }\n\n private clearCacheDependencies(cacheName: CacheNames | 'all', key?: string) {\n if (cacheName === 'all') {\n this.barrelManifestDependencies.clear();\n this.exportDependencies.clear();\n return;\n }\n\n if (cacheName === 'barrelManifests') {\n if (key === undefined) {\n this.barrelManifestDependencies.clear();\n } else {\n this.barrelManifestDependencies.delete(key);\n }\n return;\n }\n\n if (cacheName === 'exports') {\n if (key === undefined) {\n this.exportDependencies.clear();\n } else {\n this.exportDependencies.delete(key);\n }\n }\n }\n\n private getCachedDependencies(filename: string): Set<string> {\n return new Set([\n ...(this.barrelManifestDependencies.get(filename) ?? []),\n ...(this.exportDependencies.get(filename) ?? []),\n ]);\n }\n\n private getDependencyCache(cacheName: 'barrelManifests' | 'exports') {\n return cacheName === 'barrelManifests'\n ? this.barrelManifestDependencies\n : this.exportDependencies;\n }\n\n private hasCachedDependencies(filename: string): boolean {\n return this.getCachedDependencies(filename).size > 0;\n }\n\n private setContentHash(\n filename: string,\n source: 'fs' | 'loaded',\n hash: string\n ) {\n const current = this.contentHashes.get(filename);\n if (current) {\n current[source] = hash;\n return;\n }\n\n this.contentHashes.set(filename, { [source]: hash });\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,QAAQ;AACnC,OAAOC,EAAE,MAAM,SAAS;AACxB,SAASC,MAAM,QAAQ,mBAAm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IAChD,IAAIiC,OAAO,EAAE;MACXA,OAAO,CAAC5C,MAAM,CAAC,GAAG2C,IAAI;MACtB;IACF;IAEA,IAAI,CAAChE,aAAa,CAACgB,GAAG,CAACgB,QAAQ,EAAE;MAAE,CAACX,MAAM,GAAG2C;IAAK,CAAC,CAAC;EACtD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"cache.js","names":["createHash","fs","logger","getFileIdx","stripQueryAndHash","hashContent","content","update","digest","isMissingFileError","error","code","cacheLogger","extend","cacheNames","loggers","reduce","acc","key","TransformCacheCollection","barrelManifestDependencies","Map","contentHashes","fileMtimes","exportDependencies","constructor","caches","barrelManifests","entrypoints","exports","add","cacheName","value","cache","undefined","has","get","delete","clearCacheDependencies","set","maybeOriginalCode","originalCode","isLoaded","initialCode","source","resolvedCode","setContentHash","fileContent","readFileSync","clear","forEach","name","invalidate","res","invalidateForFile","filename","invalidateIfChanged","previousVisitedFiles","changedFiles","Set","visitedFiles","fileEntrypoint","anyDepChanged","hasCachedDependencies","invalidateOnDependencyChange","dependenciesToCheck","dependency","dependencies","invalidationDependencies","dependencyFilename","getCachedDependencies","values","some","resolved","dependencyContent","dependencyChanged","existing","previousHash","newHash","otherSource","otherHash","setCacheDependencies","getDependencyCache","nextDependencies","filter","length","size","checkFreshness","strippedFilename","currentMtime","statSync","mtimeMs","cachedMtime","hash","current"],"sources":["../src/cache.ts"],"sourcesContent":["import { createHash } from 'crypto';\nimport fs from 'node:fs';\nimport { logger } from '@wyw-in-js/shared';\n\nimport type { BarrelManifestCacheEntry } from './transform/barrelManifest';\nimport type { Entrypoint } from './transform/Entrypoint';\nimport type { IEvaluatedEntrypoint } from './transform/EvaluatedEntrypoint';\nimport { getFileIdx } from './utils/getFileIdx';\nimport { stripQueryAndHash } from './utils/parseRequest';\n\nfunction hashContent(content: string) {\n return createHash('sha256').update(content).digest('hex');\n}\n\nfunction isMissingFileError(error: unknown): boolean {\n if (!error || typeof error !== 'object') {\n return false;\n }\n\n const { code } = error as NodeJS.ErrnoException;\n return code === 'ENOENT' || code === 'ENOTDIR';\n}\n\ninterface IBaseCachedEntrypoint {\n dependencies: Map<string, { resolved: string | null }>;\n initialCode?: string;\n invalidateOnDependencyChange?: Set<string>;\n invalidationDependencies?: Map<string, { resolved: string | null }>;\n}\n\ninterface ICaches<TEntrypoint extends IBaseCachedEntrypoint> {\n barrelManifests: Map<string, BarrelManifestCacheEntry>;\n entrypoints: Map<string, TEntrypoint>;\n exports: Map<string, string[]>;\n}\n\ntype MapValue<T> = T extends Map<string, infer V> ? V : never;\n\nconst cacheLogger = logger.extend('cache');\n\nconst cacheNames = ['barrelManifests', 'entrypoints', 'exports'] as const;\ntype CacheNames = (typeof cacheNames)[number];\n\nconst loggers = cacheNames.reduce(\n (acc, key) => ({\n ...acc,\n [key]: cacheLogger.extend(key),\n }),\n {} as Record<CacheNames, typeof logger>\n);\n\nexport class TransformCacheCollection<\n TEntrypoint extends IBaseCachedEntrypoint = Entrypoint | IEvaluatedEntrypoint,\n> {\n public readonly barrelManifests: Map<string, BarrelManifestCacheEntry>;\n\n public readonly entrypoints: Map<string, TEntrypoint>;\n\n public readonly exports: Map<string, string[]>;\n\n private readonly barrelManifestDependencies = new Map<string, Set<string>>();\n\n private contentHashes = new Map<string, { fs?: string; loaded?: string }>();\n\n private fileMtimes = new Map<string, number>();\n\n private readonly exportDependencies = new Map<string, Set<string>>();\n\n constructor(caches: Partial<ICaches<TEntrypoint>> = {}) {\n this.barrelManifests = caches.barrelManifests || new Map();\n this.entrypoints = caches.entrypoints || new Map();\n this.exports = caches.exports || new Map();\n }\n\n public add<\n TCache extends CacheNames,\n TValue extends MapValue<ICaches<TEntrypoint>[TCache]>,\n >(cacheName: TCache, key: string, value: TValue): void {\n const cache = this[cacheName] as Map<string, TValue>;\n loggers[cacheName]('%s:add %s %f', getFileIdx(key), key, () => {\n if (value === undefined) {\n return cache.has(key) ? 'removed' : 'noop';\n }\n\n if (!cache.has(key)) {\n return 'added';\n }\n\n return cache.get(key) === value ? 'unchanged' : 'updated';\n });\n\n if (value === undefined) {\n cache.delete(key);\n this.contentHashes.delete(key);\n this.clearCacheDependencies(cacheName, key);\n return;\n }\n\n this.clearCacheDependencies(cacheName, key);\n cache.set(key, value);\n\n if ('initialCode' in value) {\n const maybeOriginalCode = (value as unknown as { originalCode?: unknown })\n .originalCode;\n const isLoaded = typeof value.initialCode === 'string';\n const source = isLoaded ? 'loaded' : 'fs';\n\n let resolvedCode: string | undefined;\n if (isLoaded) {\n resolvedCode = value.initialCode;\n } else if (typeof maybeOriginalCode === 'string') {\n resolvedCode = maybeOriginalCode;\n }\n\n if (resolvedCode !== undefined) {\n this.setContentHash(key, source, hashContent(resolvedCode));\n return;\n }\n\n try {\n const fileContent = fs.readFileSync(stripQueryAndHash(key), 'utf8');\n this.setContentHash(key, source, hashContent(fileContent));\n } catch {\n this.setContentHash(key, source, hashContent(''));\n }\n\n return;\n }\n\n if (cacheName === 'barrelManifests') {\n try {\n const fileContent = fs.readFileSync(stripQueryAndHash(key), 'utf8');\n this.setContentHash(key, 'fs', hashContent(fileContent));\n } catch {\n this.setContentHash(key, 'fs', hashContent(''));\n }\n }\n }\n\n public clear(cacheName: CacheNames | 'all'): void {\n if (cacheName === 'all') {\n cacheNames.forEach((name) => {\n this.clear(name);\n });\n\n return;\n }\n\n loggers[cacheName]('clear');\n const cache = this[cacheName] as Map<string, unknown>;\n\n cache.clear();\n this.clearCacheDependencies(cacheName);\n }\n\n public delete(cacheName: CacheNames, key: string): void {\n this.invalidate(cacheName, key);\n }\n\n public get<\n TCache extends CacheNames,\n TValue extends MapValue<ICaches<TEntrypoint>[TCache]>,\n >(cacheName: TCache, key: string): TValue | undefined {\n const cache = this[cacheName] as Map<string, TValue>;\n\n const res = cache.get(key);\n loggers[cacheName]('get', key, res === undefined ? 'miss' : 'hit');\n return res;\n }\n\n public has(cacheName: CacheNames, key: string): boolean {\n const cache = this[cacheName] as Map<string, unknown>;\n\n const res = cache.has(key);\n loggers[cacheName]('has', key, res);\n return res;\n }\n\n public invalidate(cacheName: CacheNames, key: string): void {\n const cache = this[cacheName] as Map<string, unknown>;\n if (!cache.has(key)) {\n return;\n }\n\n loggers[cacheName]('invalidate', key);\n\n cache.delete(key);\n this.clearCacheDependencies(cacheName, key);\n }\n\n public invalidateForFile(filename: string) {\n cacheNames.forEach((cacheName) => {\n this.invalidate(cacheName, filename);\n });\n }\n\n public invalidateIfChanged(\n filename: string,\n content: string,\n previousVisitedFiles?: Set<string>,\n source: 'fs' | 'loaded' = 'loaded',\n changedFiles = new Set<string>()\n ) {\n if (changedFiles.has(filename)) {\n return true;\n }\n\n const visitedFiles = new Set(previousVisitedFiles);\n const fileEntrypoint = this.get('entrypoints', filename);\n let anyDepChanged = false;\n\n // We need to check all dependencies of the file\n // because they might have changed as well.\n if (\n !visitedFiles.has(filename) &&\n (fileEntrypoint || this.hasCachedDependencies(filename))\n ) {\n visitedFiles.add(filename);\n const invalidateOnDependencyChange =\n fileEntrypoint?.invalidateOnDependencyChange;\n\n const dependenciesToCheck = new Map<\n string,\n { resolved: string | null }\n >();\n\n for (const [key, dependency] of fileEntrypoint?.dependencies ?? []) {\n dependenciesToCheck.set(key, dependency);\n }\n\n for (const [\n key,\n dependency,\n ] of fileEntrypoint?.invalidationDependencies ?? []) {\n if (!dependenciesToCheck.has(key)) {\n dependenciesToCheck.set(key, dependency);\n }\n }\n\n for (const dependencyFilename of this.getCachedDependencies(filename)) {\n if (\n ![...dependenciesToCheck.values()].some(\n (dependency) => dependency.resolved === dependencyFilename\n )\n ) {\n dependenciesToCheck.set(dependencyFilename, {\n resolved: dependencyFilename,\n });\n }\n }\n\n for (const [, dependency] of dependenciesToCheck) {\n const dependencyFilename = dependency.resolved;\n\n if (dependencyFilename) {\n let dependencyContent: string;\n try {\n dependencyContent = fs.readFileSync(\n stripQueryAndHash(dependencyFilename),\n 'utf8'\n );\n } catch (error) {\n if (!isMissingFileError(error)) {\n throw error;\n }\n\n this.invalidateForFile(dependencyFilename);\n anyDepChanged = true;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const dependencyChanged = this.invalidateIfChanged(\n dependencyFilename,\n dependencyContent,\n visitedFiles,\n 'fs',\n changedFiles\n );\n\n if (\n dependencyChanged &&\n invalidateOnDependencyChange?.has(dependencyFilename)\n ) {\n cacheLogger(\n 'dependency affecting output has changed, invalidate all for %s',\n filename\n );\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n if (dependencyChanged) {\n anyDepChanged = true;\n }\n }\n }\n }\n\n const existing = this.contentHashes.get(filename);\n const previousHash = existing?.[source];\n const newHash = hashContent(content);\n\n if (previousHash === undefined) {\n const otherSource = source === 'fs' ? 'loaded' : 'fs';\n const otherHash = existing?.[otherSource];\n\n if ((otherHash !== undefined && otherHash !== newHash) || anyDepChanged) {\n cacheLogger('content has changed, invalidate all for %s', filename);\n this.setContentHash(filename, source, newHash);\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n this.setContentHash(filename, source, newHash);\n if (anyDepChanged) {\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n return true;\n }\n return false;\n }\n\n if (previousHash !== newHash || anyDepChanged) {\n cacheLogger('content has changed, invalidate all for %s', filename);\n this.setContentHash(filename, source, newHash);\n this.invalidateForFile(filename);\n changedFiles.add(filename);\n\n return true;\n }\n\n return false;\n }\n\n public setCacheDependencies(\n cacheName: 'barrelManifests' | 'exports',\n key: string,\n dependencies: Iterable<string>\n ): void {\n const cache = this.getDependencyCache(cacheName);\n const nextDependencies = new Set(\n [...dependencies].filter((dependency) => dependency.length > 0)\n );\n\n if (nextDependencies.size === 0) {\n cache.delete(key);\n return;\n }\n\n cache.set(key, nextDependencies);\n }\n\n private clearCacheDependencies(cacheName: CacheNames | 'all', key?: string) {\n if (cacheName === 'all') {\n this.barrelManifestDependencies.clear();\n this.exportDependencies.clear();\n return;\n }\n\n if (cacheName === 'barrelManifests') {\n if (key === undefined) {\n this.barrelManifestDependencies.clear();\n } else {\n this.barrelManifestDependencies.delete(key);\n }\n return;\n }\n\n if (cacheName === 'exports') {\n if (key === undefined) {\n this.exportDependencies.clear();\n } else {\n this.exportDependencies.delete(key);\n }\n }\n }\n\n private getCachedDependencies(filename: string): Set<string> {\n return new Set([\n ...(this.barrelManifestDependencies.get(filename) ?? []),\n ...(this.exportDependencies.get(filename) ?? []),\n ]);\n }\n\n private getDependencyCache(cacheName: 'barrelManifests' | 'exports') {\n return cacheName === 'barrelManifests'\n ? this.barrelManifestDependencies\n : this.exportDependencies;\n }\n\n private hasCachedDependencies(filename: string): boolean {\n return this.getCachedDependencies(filename).size > 0;\n }\n\n /**\n * Fast check if a file changed on disk since last seen.\n * Uses mtime as a fast path — only reads the file if mtime differs.\n * Returns true if the file changed (cache was invalidated).\n */\n public checkFreshness(filename: string, strippedFilename: string): boolean {\n try {\n const currentMtime = fs.statSync(strippedFilename).mtimeMs;\n const cachedMtime = this.fileMtimes.get(filename);\n\n if (cachedMtime !== undefined && currentMtime === cachedMtime) {\n return false;\n }\n\n const content = fs.readFileSync(strippedFilename, 'utf-8');\n this.fileMtimes.set(filename, currentMtime);\n\n if (this.invalidateIfChanged(filename, content, undefined, 'fs')) {\n return true;\n }\n\n return false;\n } catch (error) {\n if (!isMissingFileError(error)) {\n throw error;\n }\n\n this.invalidateForFile(filename);\n return true;\n }\n }\n\n private setContentHash(\n filename: string,\n source: 'fs' | 'loaded',\n hash: string\n ) {\n const current = this.contentHashes.get(filename);\n if (current) {\n current[source] = hash;\n } else {\n this.contentHashes.set(filename, { [source]: hash });\n }\n\n if (source === 'fs') {\n try {\n this.fileMtimes.set(\n filename,\n fs.statSync(stripQueryAndHash(filename)).mtimeMs\n );\n } catch {\n // ignore\n }\n }\n }\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,QAAQ;AACnC,OAAOC,EAAE,MAAM,SAAS;AACxB,SAASC,MAAM,QAAQ,mBAAmB;AAK1C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,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AAG,IAAI,CAACxE,aAAa,CAACc,GAAG,CAACmB,QAAQ,CAAC;IAChD,IAAIuC,OAAO,EAAE;MACXA,OAAO,CAAClD,MAAM,CAAC,GAAGiD,IAAI;IACxB,CAAC,MAAM;MACL,IAAI,CAACvE,aAAa,CAACiB,GAAG,CAACgB,QAAQ,EAAE;QAAE,CAACX,MAAM,GAAGiD;MAAK,CAAC,CAAC;IACtD;IAEA,IAAIjD,MAAM,KAAK,IAAI,EAAE;MACnB,IAAI;QACF,IAAI,CAACrB,UAAU,CAACgB,GAAG,CACjBgB,QAAQ,EACRtD,EAAE,CAACyF,QAAQ,CAACtF,iBAAiB,CAACmD,QAAQ,CAAC,CAAC,CAACoC,OAC3C,CAAC;MACH,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ;EACF;AACF","ignoreList":[]}
package/esm/module.js CHANGED
@@ -298,10 +298,15 @@ export class Module {
298
298
  if (extension !== '.json' && !this.extensions.includes(extension)) {
299
299
  return null;
300
300
  }
301
- const entrypoint = this.cache.get('entrypoints', filename);
301
+ let entrypoint = this.cache.get('entrypoints', filename);
302
302
  if (entrypoint && isSuperSet(entrypoint.evaluatedOnly ?? [], only)) {
303
- log('✅ file has been already evaluated');
304
- return entrypoint;
303
+ if (this.cache.checkFreshness(filename, strippedFilename)) {
304
+ entrypoint = undefined;
305
+ }
306
+ if (entrypoint) {
307
+ log('✅ file has been already evaluated');
308
+ return entrypoint;
309
+ }
305
310
  }
306
311
  if (entrypoint?.ignored) {
307
312
  log('✅ file has been ignored during prepare stage. Original code will be used');
package/esm/module.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","names":["fs","NativeModule","path","vm","invariant","isFeatureEnabled","Entrypoint","getStack","isSuperSet","mergeOnly","isUnprocessedEntrypointError","applyImportOverrideToOnly","getImportOverride","resolveMockSpecifier","toImportKey","parseRequest","stripQueryAndHash","createVmContext","CJS_DEFAULT_CONDITIONS","expandConditions","conditionNames","result","Set","name","d","add","isBarePackageSubpath","id","startsWith","isAbsolute","split","length","includes","DefaultModuleImplementation","builtins","assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","http","https","module","net","os","punycode","process","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","zlib","VITE_VIRTUAL_PREFIX","REACT_REFRESH_VIRTUAL_ID","reactRefreshRuntime","createSignatureFunctionForTransform","NOOP","browserOnlyEvalHintTriggers","getBrowserOnlyEvalHint","error","message","Error","String","looksLikeBrowserOnly","some","trigger","join","warnedUnknownImportsByServices","WeakMap","emitWarning","services","warn","getWarnedUnknownImports","cached","get","created","set","getUncached","test","cachedSet","has","filter","t","resolve","resolved","resolveDependency","defaultImportLoaders","raw","Module","callstack","isEvaluated","require","Object","assign","dependencies","push","debug","dependency","source","loaded","loadByImportLoaders","handled","value","entrypoint","getEntrypoint","only","evaluated","evaluatedOnly","exports","m","createChild","evaluate","ensure","bind","entrypointRef","constructor","parentModule","moduleImpl","cache","options","pluginOptions","features","WeakRef","idx","filename","log","extend","parentIsIgnored","ignored","extensions","deref","assertTransformed","evaluatedCreated","supersededWith","createEvaluated","transformedCode","JSON","parse","context","teardown","__wyw_dynamic_import","__dirname","dirname","overrideContext","script","Script","runInContext","e","EvalError","baseMessage","hint","strippedFilename","extension","extname","newEntrypoint","readFileSync","stack","uncachedExports","reprocessOnly","evaluatedExports","code","createRoot","resolveWithConditions","parent","conditions","resolveOptions","undefined","shouldRetryWithExtensions","_resolveFilename","ext","getDependency","Promise","_extensions","added","forEach","strippedId","paths","_nodeModulePaths","isFileSpecifier","endsWith","existsSync","slice","root","keyInfo","override","importOverrides","key","policy","unknown","mock","shouldWarn","finalResolved","importer","errorMessage","map","item","Boolean","warnedUnknownImports","stringify","request","importLoaders","query","hash","params","URLSearchParams","matchedKey","Array","from","keys","find","loader","importerDir","toUrl","relative","replace","posix","sep","readFile"],"sources":["../src/module.ts"],"sourcesContent":["/**\n * This is a custom implementation for the module system for evaluating code,\n * used for resolving values for dependencies interpolated in `css` or `styled`.\n *\n * This serves 2 purposes:\n * - Avoid leakage from evaluated code to module cache in current context, e.g. `babel-register`\n * - Allow us to invalidate the module cache without affecting other stuff, necessary for rebuilds\n *\n * We also use it to transpile the code with Babel by default.\n * We also store source maps for it to provide correct error stacktraces.\n *\n */\n\nimport fs from 'fs';\nimport NativeModule from 'module';\nimport path from 'path';\nimport vm from 'vm';\n\nimport { invariant } from 'ts-invariant';\n\nimport {\n isFeatureEnabled,\n type Debugger,\n type ImportLoaderContext,\n type ImportLoaders,\n} from '@wyw-in-js/shared';\n\nimport './utils/dispose-polyfill';\nimport type { TransformCacheCollection } from './cache';\nimport { Entrypoint } from './transform/Entrypoint';\nimport {\n getStack,\n isSuperSet,\n mergeOnly,\n} from './transform/Entrypoint.helpers';\nimport type { IEntrypointDependency } from './transform/Entrypoint.types';\nimport type { IEvaluatedEntrypoint } from './transform/EvaluatedEntrypoint';\nimport { isUnprocessedEntrypointError } from './transform/actions/UnprocessedEntrypointError';\nimport type { Services } from './transform/types';\nimport {\n applyImportOverrideToOnly,\n getImportOverride,\n resolveMockSpecifier,\n toImportKey,\n} from './utils/importOverrides';\nimport { parseRequest, stripQueryAndHash } from './utils/parseRequest';\nimport { createVmContext } from './vm/createVmContext';\n\ntype HiddenModuleMembers = {\n _extensions: Record<string, () => void>;\n _resolveFilename: (\n id: string,\n options: { filename: string; id: string; paths: string[] },\n isMain?: boolean,\n resolveOptions?: { conditions?: Set<string> }\n ) => string;\n _nodeModulePaths(filename: string): string[];\n};\n\nconst CJS_DEFAULT_CONDITIONS = ['require', 'node', 'default'] as const;\n\nfunction expandConditions(conditionNames: string[]): Set<string> {\n const result = new Set<string>();\n for (const name of conditionNames) {\n if (name === '...') {\n for (const d of CJS_DEFAULT_CONDITIONS) result.add(d);\n } else {\n result.add(name);\n }\n }\n return result;\n}\n\nfunction isBarePackageSubpath(id: string): boolean {\n if (id.startsWith('.') || path.isAbsolute(id)) {\n return false;\n }\n\n if (id.startsWith('@')) {\n return id.split('/').length > 2;\n }\n\n return id.includes('/');\n}\n\nexport const DefaultModuleImplementation = NativeModule as typeof NativeModule &\n HiddenModuleMembers;\n\n// Supported node builtins based on the modules polyfilled by webpack\n// `true` means module is polyfilled, `false` means module is empty\nconst builtins = {\n assert: true,\n buffer: true,\n child_process: false,\n cluster: false,\n console: true,\n constants: true,\n crypto: true,\n dgram: false,\n dns: false,\n domain: true,\n events: true,\n fs: false,\n http: true,\n https: true,\n module: false,\n net: false,\n os: true,\n path: true,\n punycode: true,\n process: true,\n querystring: true,\n readline: false,\n repl: false,\n stream: true,\n string_decoder: true,\n sys: true,\n timers: true,\n tls: false,\n tty: true,\n url: true,\n util: true,\n vm: true,\n zlib: true,\n};\n\nconst VITE_VIRTUAL_PREFIX = '/@';\nconst REACT_REFRESH_VIRTUAL_ID = '/@react-refresh';\nconst reactRefreshRuntime = {\n createSignatureFunctionForTransform: () => () => {},\n};\n\nconst NOOP = () => {};\n\nconst browserOnlyEvalHintTriggers = [\n 'window is not defined',\n \"evaluating 'window\",\n 'document is not defined',\n \"evaluating 'document\",\n 'navigator is not defined',\n \"evaluating 'navigator\",\n 'self is not defined',\n \"evaluating 'self\",\n];\n\nconst getBrowserOnlyEvalHint = (error: unknown): string | null => {\n const message = error instanceof Error ? error.message : String(error);\n const looksLikeBrowserOnly = browserOnlyEvalHintTriggers.some((trigger) =>\n message.includes(trigger)\n );\n if (!looksLikeBrowserOnly) return null;\n\n return [\n '',\n '[wyw-in-js] Evaluation hint:',\n 'This usually means browser-only code ran during build-time evaluation.',\n 'Move browser-only initialization out of evaluated modules, or mock the import via `importOverrides`.',\n \"Example: importOverrides: { 'msw/browser': { mock: './src/__mocks__/msw-browser.js' } }\",\n ].join('\\n');\n};\n\nconst warnedUnknownImportsByServices = new WeakMap<Services, Set<string>>();\n\nfunction emitWarning(services: Services, message: string) {\n if (services.emitWarning) {\n services.emitWarning(message);\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(message);\n}\n\nfunction getWarnedUnknownImports(services: Services): Set<string> {\n const cached = warnedUnknownImportsByServices.get(services);\n if (cached) {\n return cached;\n }\n\n const created = new Set<string>();\n warnedUnknownImportsByServices.set(services, created);\n return created;\n}\n\nfunction getUncached(cached: string | string[], test: string[]): string[] {\n const cachedSet = new Set(\n typeof cached === 'string' ? cached.split(',') : cached\n );\n\n if (cachedSet.has('*')) {\n return [];\n }\n\n return test.filter((t) => !cachedSet.has(t));\n}\n\nfunction resolve(\n this: { resolveDependency: (id: string) => IEntrypointDependency },\n id: string\n): string {\n const { resolved } = this.resolveDependency(id);\n invariant(resolved, `Unable to resolve \"${id}\"`);\n return resolved;\n}\n\nconst defaultImportLoaders: ImportLoaders = {\n raw: 'raw',\n url: 'url',\n};\n\nexport class Module {\n public readonly callstack: string[] = [];\n\n public readonly debug: Debugger;\n\n public readonly dependencies: string[];\n\n public readonly extensions: string[];\n\n public readonly filename: string;\n\n public id: string;\n\n public readonly idx: string;\n\n public readonly ignored: boolean;\n\n public isEvaluated: boolean = false;\n\n public readonly parentIsIgnored: boolean;\n\n public require: {\n (id: string): unknown;\n ensure: () => void;\n resolve: (id: string) => string;\n } = Object.assign(\n (id: string) => {\n if (id === REACT_REFRESH_VIRTUAL_ID) {\n this.dependencies.push(id);\n this.debug('require', `vite virtual '${id}'`);\n return reactRefreshRuntime;\n }\n\n if (id.startsWith(VITE_VIRTUAL_PREFIX)) {\n this.dependencies.push(id);\n this.debug('require', `vite virtual '${id}'`);\n return {};\n }\n\n if (id in builtins) {\n // The module is in the allowed list of builtin node modules\n // Ideally we should prevent importing them, but webpack polyfills some\n // So we check for the list of polyfills to determine which ones to support\n if (builtins[id as keyof typeof builtins]) {\n this.debug('require', `builtin '${id}'`);\n return require(id);\n }\n\n return null;\n }\n\n // Resolve module id (and filename) relatively to parent module\n const dependency = this.resolveDependency(id);\n if (dependency.resolved === id && !path.isAbsolute(id)) {\n // The module is a builtin node modules, but not in the allowed list\n throw new Error(\n `Unable to import \"${id}\". Importing Node builtins is not supported in the sandbox.`\n );\n }\n\n invariant(\n dependency.resolved,\n `Dependency ${dependency.source} cannot be resolved`\n );\n\n const loaded = this.loadByImportLoaders(id, dependency.resolved);\n if (loaded.handled) {\n this.dependencies.push(id);\n this.debug('require', `${id} -> ${dependency.resolved} (loader)`);\n return loaded.value;\n }\n\n this.dependencies.push(id);\n\n this.debug('require', `${id} -> ${dependency.resolved}`);\n\n const entrypoint = this.getEntrypoint(\n dependency.resolved,\n dependency.only,\n this.debug\n );\n\n if (entrypoint === null) {\n return dependency.resolved;\n }\n\n if (\n entrypoint.evaluated ||\n isSuperSet(entrypoint.evaluatedOnly, dependency.only)\n ) {\n return entrypoint.exports;\n }\n\n const m = this.createChild(entrypoint);\n m.evaluate();\n\n return entrypoint.exports;\n },\n {\n ensure: NOOP,\n resolve: resolve.bind(this),\n }\n );\n\n public resolve = resolve.bind(this);\n\n private cache: TransformCacheCollection;\n\n #entrypointRef: WeakRef<Entrypoint> | Entrypoint;\n\n constructor(\n private services: Services,\n entrypoint: Entrypoint,\n parentModule?: Module,\n private moduleImpl: HiddenModuleMembers = DefaultModuleImplementation\n ) {\n this.cache = services.cache;\n this.#entrypointRef = isFeatureEnabled(\n services.options.pluginOptions.features,\n 'useWeakRefInEval',\n entrypoint.name\n )\n ? new WeakRef(entrypoint)\n : entrypoint;\n this.idx = entrypoint.idx;\n this.id = entrypoint.name;\n this.filename = entrypoint.name;\n this.dependencies = [];\n this.debug = entrypoint.log.extend('module');\n this.parentIsIgnored = parentModule?.ignored ?? false;\n this.ignored = entrypoint.ignored ?? this.parentIsIgnored;\n\n if (parentModule) {\n this.callstack = [entrypoint.name, ...parentModule.callstack];\n } else {\n this.callstack = [entrypoint.name];\n }\n\n this.extensions = services.options.pluginOptions.extensions;\n\n this.debug('init', entrypoint.name);\n }\n\n public get exports() {\n return this.entrypoint.exports;\n }\n\n public set exports(value) {\n this.entrypoint.exports = value;\n\n this.debug('the whole exports was overridden with %O', value);\n }\n\n protected get entrypoint(): Entrypoint {\n const entrypoint =\n this.#entrypointRef instanceof WeakRef\n ? this.#entrypointRef.deref()\n : this.#entrypointRef;\n invariant(entrypoint, `Module ${this.idx} is disposed`);\n return entrypoint;\n }\n\n evaluate(): void {\n const { entrypoint } = this;\n entrypoint.assertTransformed();\n\n const cached = this.cache.get('entrypoints', entrypoint.name)!;\n let evaluatedCreated = false;\n if (!entrypoint.supersededWith) {\n this.cache.add(\n 'entrypoints',\n entrypoint.name,\n entrypoint.createEvaluated()\n );\n evaluatedCreated = true;\n }\n\n const { transformedCode: source } = entrypoint;\n const { pluginOptions } = this.services.options;\n\n if (!source) {\n this.debug(`evaluate`, 'there is nothing to evaluate');\n return;\n }\n\n if (this.isEvaluated) {\n this.debug('evaluate', `is already evaluated`);\n return;\n }\n\n this.debug('evaluate');\n this.debug.extend('source')('%s', source);\n\n this.isEvaluated = true;\n\n const filename = stripQueryAndHash(this.filename);\n\n if (/\\.json$/.test(filename)) {\n // For JSON files, parse it to a JS object similar to Node\n this.exports = JSON.parse(source);\n return;\n }\n\n const { context, teardown } = createVmContext(\n filename,\n pluginOptions.features,\n {\n module: this,\n exports: entrypoint.exports,\n require: this.require,\n __wyw_dynamic_import: async (id: unknown) => this.require(String(id)),\n __dirname: path.dirname(filename),\n },\n pluginOptions.overrideContext\n );\n\n try {\n const script = new vm.Script(\n `(function (exports) { ${source}\\n})(exports);`,\n {\n filename,\n }\n );\n\n script.runInContext(context);\n } catch (e) {\n this.isEvaluated = false;\n if (evaluatedCreated) {\n this.cache.add('entrypoints', entrypoint.name, cached);\n }\n\n if (isUnprocessedEntrypointError(e)) {\n // It will be handled by evalFile scenario\n throw e;\n }\n\n if (e instanceof EvalError) {\n this.debug('%O', e);\n\n throw e;\n }\n\n this.debug('%O\\n%O', e, this.callstack);\n const baseMessage = `${(e as Error).message} in${this.callstack.join(\n '\\n| '\n )}\\n`;\n const hint = getBrowserOnlyEvalHint(e);\n\n throw new EvalError(hint ? `${baseMessage}${hint}\\n` : baseMessage);\n } finally {\n teardown();\n }\n }\n\n getEntrypoint(\n filename: string,\n only: string[],\n log: Debugger\n ): Entrypoint | IEvaluatedEntrypoint | null {\n const strippedFilename = stripQueryAndHash(filename);\n const extension = path.extname(strippedFilename);\n if (extension !== '.json' && !this.extensions.includes(extension)) {\n return null;\n }\n\n const entrypoint = this.cache.get('entrypoints', filename);\n if (entrypoint && isSuperSet(entrypoint.evaluatedOnly ?? [], only)) {\n log('✅ file has been already evaluated');\n return entrypoint;\n }\n\n if (entrypoint?.ignored) {\n log(\n '✅ file has been ignored during prepare stage. Original code will be used'\n );\n return entrypoint;\n }\n\n if (this.ignored) {\n log(\n '✅ one of the parent files has been ignored during prepare stage. Original code will be used'\n );\n\n const newEntrypoint = this.entrypoint.createChild(\n filename,\n ['*'],\n fs.readFileSync(strippedFilename, 'utf-8')\n );\n\n if (newEntrypoint === 'loop') {\n const stack = getStack(this.entrypoint);\n throw new Error(\n `Circular dependency detected: ${stack.join(' -> ')} -> ${filename}`\n );\n }\n\n return newEntrypoint;\n }\n\n let uncachedExports: string[] | null = null;\n let reprocessOnly: string[] = only;\n // Requested file can be already prepared for evaluation on the stage 1\n if (only && entrypoint) {\n const evaluatedExports =\n entrypoint.evaluatedOnly?.length !== 0\n ? entrypoint.evaluatedOnly\n : entrypoint.only ?? [];\n uncachedExports = getUncached(evaluatedExports, only);\n if (uncachedExports.length === 0) {\n log('✅ ready for evaluation');\n return entrypoint;\n }\n\n if (entrypoint.evaluatedOnly?.length) {\n reprocessOnly = mergeOnly(evaluatedExports, only);\n }\n\n log(\n '❌ file has been processed during prepare stage but %o is not evaluated yet (evaluated: %o)',\n uncachedExports,\n evaluatedExports\n );\n } else {\n log('❌ file has not been processed during prepare stage');\n }\n\n // If code wasn't extracted from cache, it indicates that we were unable\n // to process some of the imports on stage1. Let's try to reprocess.\n const code = fs.readFileSync(strippedFilename, 'utf-8');\n const newEntrypoint = Entrypoint.createRoot(\n this.services,\n filename,\n reprocessOnly,\n code\n );\n\n if (newEntrypoint.evaluated) {\n log('✅ file has been already evaluated');\n return newEntrypoint;\n }\n\n if (newEntrypoint.ignored) {\n log(\n '✅ file has been ignored during prepare stage. Original code will be used'\n );\n return newEntrypoint;\n }\n\n return newEntrypoint;\n }\n\n private resolveWithConditions(\n id: string,\n parent: { id: string; filename: string; paths: string[] },\n conditions?: Set<string>\n ): string {\n const resolveOptions = conditions ? { conditions } : undefined;\n const shouldRetryWithExtensions =\n conditions &&\n path.extname(id) === '' &&\n (id.startsWith('.') || path.isAbsolute(id) || isBarePackageSubpath(id));\n try {\n return this.moduleImpl._resolveFilename(\n id,\n parent,\n false,\n resolveOptions\n );\n } catch (e: unknown) {\n if (\n shouldRetryWithExtensions &&\n e instanceof Error &&\n (e as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND'\n ) {\n // Extensionless subpath requests (e.g. \"pkg/src/*\" or \"./src/*\") may\n // resolve to extensionless targets via conditional exports. Retry with\n // each known extension, but never rewrite already explicit specifiers.\n for (const ext of this.extensions) {\n try {\n return this.moduleImpl._resolveFilename(\n id + ext,\n parent,\n false,\n resolveOptions\n );\n } catch {\n // try next extension\n }\n }\n }\n throw e;\n }\n }\n\n resolveDependency = (id: string): IEntrypointDependency => {\n const cached = this.entrypoint.getDependency(id);\n invariant(!(cached instanceof Promise), 'Dependency is not resolved yet');\n\n if (cached) {\n return cached;\n }\n\n if (!this.ignored) {\n this.debug(\n '❌ import has not been resolved during prepare stage. Fallback to Node.js resolver'\n );\n }\n\n const extensions = this.moduleImpl._extensions;\n const added: string[] = [];\n\n try {\n // Check for supported extensions\n this.extensions.forEach((ext) => {\n if (ext in extensions) {\n return;\n }\n\n // When an extension is not supported, add it\n // And keep track of it to clean it up after resolving\n // Use noop for the transform function since we handle it\n extensions[ext] = NOOP;\n added.push(ext);\n });\n\n const { filename } = this;\n const strippedId = stripQueryAndHash(id);\n\n const parent = {\n id: filename,\n filename,\n paths: this.moduleImpl._nodeModulePaths(path.dirname(filename)),\n };\n const { conditionNames } = this.services.options.pluginOptions;\n const conditions = conditionNames?.length\n ? expandConditions(conditionNames)\n : undefined;\n\n let resolved = this.resolveWithConditions(strippedId, parent, conditions);\n\n const isFileSpecifier =\n strippedId.startsWith('.') || path.isAbsolute(strippedId);\n\n if (\n isFileSpecifier &&\n path.extname(strippedId) === '' &&\n resolved.endsWith('.cjs') &&\n fs.existsSync(`${resolved.slice(0, -4)}.js`)\n ) {\n // When both `.cjs` and `.js` exist for an extensionless specifier, the\n // resolver may pick `.cjs` depending on the environment/extensions.\n // Prefer `.js` to keep resolved paths stable (e.g. importOverrides keys).\n resolved = `${resolved.slice(0, -4)}.js`;\n }\n\n const { root } = this.services.options;\n const keyInfo = toImportKey({\n source: id,\n resolved,\n root,\n });\n\n const override = getImportOverride(\n this.services.options.pluginOptions.importOverrides,\n keyInfo.key\n );\n\n const policy = override?.unknown ?? (override?.mock ? 'allow' : 'warn');\n const shouldWarn = !this.ignored && policy === 'warn';\n\n let finalResolved = resolved;\n if (override?.mock) {\n try {\n finalResolved = resolveMockSpecifier({\n mock: override.mock,\n importer: filename,\n root,\n stack: this.callstack,\n });\n } catch (e) {\n const errorMessage = String((e as Error)?.message ?? e);\n throw new Error(\n `[wyw-in-js] Failed to resolve import mock for \"${keyInfo.key}\" (${id} from ${filename}): ${errorMessage}`\n );\n }\n }\n\n if (policy === 'error') {\n throw new Error(\n [\n `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,\n ``,\n `importer: ${filename}`,\n `source: ${id}`,\n `resolved: ${resolved}`,\n override?.mock\n ? `mock: ${override.mock} -> ${finalResolved}`\n : ``,\n ``,\n `callstack:`,\n ...this.callstack.map((item) => ` ${item}`),\n ``,\n `config key: ${keyInfo.key}`,\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n const warnedUnknownImports = getWarnedUnknownImports(this.services);\n\n if (shouldWarn && !warnedUnknownImports.has(keyInfo.key)) {\n warnedUnknownImports.add(keyInfo.key);\n emitWarning(\n this.services,\n [\n `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,\n ``,\n `importer: ${filename}`,\n `source: ${id}`,\n `resolved: ${resolved}`,\n override?.mock\n ? `mock: ${override.mock} -> ${finalResolved}`\n : ``,\n ``,\n `callstack:`,\n ...this.callstack.map((item) => ` ${item}`),\n ``,\n `config key: ${keyInfo.key}`,\n `hint: add { importOverrides: { ${JSON.stringify(\n keyInfo.key\n )}: { unknown: 'allow' } } } to silence warnings, or use { mock } / { noShake: true } overrides.`,\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n return {\n source: id,\n only: applyImportOverrideToOnly(['*'], override),\n resolved: finalResolved,\n };\n } finally {\n // Cleanup the extensions we added to restore previous behaviour\n added.forEach((ext) => delete extensions[ext]);\n }\n };\n\n protected createChild(entrypoint: Entrypoint): Module {\n return new Module(this.services, entrypoint, this, this.moduleImpl);\n }\n\n private loadByImportLoaders(\n request: string,\n resolved: string\n ): { handled: boolean; value: unknown } {\n const { pluginOptions } = this.services.options;\n const importLoaders =\n pluginOptions.importLoaders === undefined\n ? defaultImportLoaders\n : { ...defaultImportLoaders, ...pluginOptions.importLoaders };\n\n const { query, hash } = parseRequest(request);\n if (!query) return { handled: false, value: undefined };\n\n const params = new URLSearchParams(query);\n const matchedKey = Array.from(params.keys()).find(\n (key) => importLoaders[key] !== undefined && importLoaders[key] !== false\n );\n\n if (!matchedKey) return { handled: false, value: undefined };\n\n const loader = importLoaders[matchedKey];\n\n const filename = stripQueryAndHash(resolved);\n const importer = stripQueryAndHash(this.filename);\n const importerDir = path.dirname(importer);\n\n const toUrl = () => {\n const relative = path\n .relative(importerDir, filename)\n .replace(/\\\\/g, path.posix.sep);\n\n if (relative.startsWith('.') || path.isAbsolute(relative)) {\n return relative;\n }\n\n return `./${relative}`;\n };\n\n const readFile = () => fs.readFileSync(filename, 'utf-8');\n\n const context: ImportLoaderContext = {\n importer,\n request,\n resolved,\n filename,\n query,\n hash,\n emitWarning: (message) => emitWarning(this.services, message),\n readFile,\n toUrl,\n };\n\n if (loader === 'raw') {\n return { handled: true, value: context.readFile() };\n }\n\n if (loader === 'url') {\n return { handled: true, value: context.toUrl() };\n }\n\n if (typeof loader === 'function') {\n return { handled: true, value: loader(context) };\n }\n\n return { handled: false, value: undefined };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,SAAS,QAAQ,cAAc;AAExC,SACEC,gBAAgB,QAIX,mBAAmB;AAE1B,OAAO,0BAA0B;AAEjC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SACEC,QAAQ,EACRC,UAAU,EACVC,SAAS,QACJ,gCAAgC;AAGvC,SAASC,4BAA4B,QAAQ,gDAAgD;AAE7F,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,oBAAoB,EACpBC,WAAW,QACN,yBAAyB;AAChC,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,sBAAsB;AACtE,SAASC,eAAe,QAAQ,sBAAsB;AAatD,MAAMC,sBAAsB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAU;AAEtE,SAASC,gBAAgBA,CAACC,cAAwB,EAAe;EAC/D,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;EAChC,KAAK,MAAMC,IAAI,IAAIH,cAAc,EAAE;IACjC,IAAIG,IAAI,KAAK,KAAK,EAAE;MAClB,KAAK,MAAMC,CAAC,IAAIN,sBAAsB,EAAEG,MAAM,CAACI,GAAG,CAACD,CAAC,CAAC;IACvD,CAAC,MAAM;MACLH,MAAM,CAACI,GAAG,CAACF,IAAI,CAAC;IAClB;EACF;EACA,OAAOF,MAAM;AACf;AAEA,SAASK,oBAAoBA,CAACC,EAAU,EAAW;EACjD,IAAIA,EAAE,CAACC,UAAU,C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","vm","invariant","isFeatureEnabled","Entrypoint","getStack","isSuperSet","mergeOnly","isUnprocessedEntrypointError","applyImportOverrideToOnly","getImportOverride","resolveMockSpecifier","toImportKey","parseRequest","stripQueryAndHash","createVmContext","CJS_DEFAULT_CONDITIONS","expandConditions","conditionNames","result","Set","name","d","add","isBarePackageSubpath","id","startsWith","isAbsolute","split","length","includes","DefaultModuleImplementation","builtins","assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","http","https","module","net","os","punycode","process","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","zlib","VITE_VIRTUAL_PREFIX","REACT_REFRESH_VIRTUAL_ID","reactRefreshRuntime","createSignatureFunctionForTransform","NOOP","browserOnlyEvalHintTriggers","getBrowserOnlyEvalHint","error","message","Error","String","looksLikeBrowserOnly","some","trigger","join","warnedUnknownImportsByServices","WeakMap","emitWarning","services","warn","getWarnedUnknownImports","cached","get","created","set","getUncached","test","cachedSet","has","filter","t","resolve","resolved","resolveDependency","defaultImportLoaders","raw","Module","callstack","isEvaluated","require","Object","assign","dependencies","push","debug","dependency","source","loaded","loadByImportLoaders","handled","value","entrypoint","getEntrypoint","only","evaluated","evaluatedOnly","exports","m","createChild","evaluate","ensure","bind","entrypointRef","constructor","parentModule","moduleImpl","cache","options","pluginOptions","features","WeakRef","idx","filename","log","extend","parentIsIgnored","ignored","extensions","deref","assertTransformed","evaluatedCreated","supersededWith","createEvaluated","transformedCode","JSON","parse","context","teardown","__wyw_dynamic_import","__dirname","dirname","overrideContext","script","Script","runInContext","e","EvalError","baseMessage","hint","strippedFilename","extension","extname","checkFreshness","undefined","newEntrypoint","readFileSync","stack","uncachedExports","reprocessOnly","evaluatedExports","code","createRoot","resolveWithConditions","parent","conditions","resolveOptions","shouldRetryWithExtensions","_resolveFilename","ext","getDependency","Promise","_extensions","added","forEach","strippedId","paths","_nodeModulePaths","isFileSpecifier","endsWith","existsSync","slice","root","keyInfo","override","importOverrides","key","policy","unknown","mock","shouldWarn","finalResolved","importer","errorMessage","map","item","Boolean","warnedUnknownImports","stringify","request","importLoaders","query","hash","params","URLSearchParams","matchedKey","Array","from","keys","find","loader","importerDir","toUrl","relative","replace","posix","sep","readFile"],"sources":["../src/module.ts"],"sourcesContent":["/**\n * This is a custom implementation for the module system for evaluating code,\n * used for resolving values for dependencies interpolated in `css` or `styled`.\n *\n * This serves 2 purposes:\n * - Avoid leakage from evaluated code to module cache in current context, e.g. `babel-register`\n * - Allow us to invalidate the module cache without affecting other stuff, necessary for rebuilds\n *\n * We also use it to transpile the code with Babel by default.\n * We also store source maps for it to provide correct error stacktraces.\n *\n */\n\nimport fs from 'fs';\nimport NativeModule from 'module';\nimport path from 'path';\nimport vm from 'vm';\n\nimport { invariant } from 'ts-invariant';\n\nimport {\n isFeatureEnabled,\n type Debugger,\n type ImportLoaderContext,\n type ImportLoaders,\n} from '@wyw-in-js/shared';\n\nimport './utils/dispose-polyfill';\nimport type { TransformCacheCollection } from './cache';\nimport { Entrypoint } from './transform/Entrypoint';\nimport {\n getStack,\n isSuperSet,\n mergeOnly,\n} from './transform/Entrypoint.helpers';\nimport type { IEntrypointDependency } from './transform/Entrypoint.types';\nimport type { IEvaluatedEntrypoint } from './transform/EvaluatedEntrypoint';\nimport { isUnprocessedEntrypointError } from './transform/actions/UnprocessedEntrypointError';\nimport type { Services } from './transform/types';\nimport {\n applyImportOverrideToOnly,\n getImportOverride,\n resolveMockSpecifier,\n toImportKey,\n} from './utils/importOverrides';\nimport { parseRequest, stripQueryAndHash } from './utils/parseRequest';\nimport { createVmContext } from './vm/createVmContext';\n\ntype HiddenModuleMembers = {\n _extensions: Record<string, () => void>;\n _resolveFilename: (\n id: string,\n options: { filename: string; id: string; paths: string[] },\n isMain?: boolean,\n resolveOptions?: { conditions?: Set<string> }\n ) => string;\n _nodeModulePaths(filename: string): string[];\n};\n\nconst CJS_DEFAULT_CONDITIONS = ['require', 'node', 'default'] as const;\n\nfunction expandConditions(conditionNames: string[]): Set<string> {\n const result = new Set<string>();\n for (const name of conditionNames) {\n if (name === '...') {\n for (const d of CJS_DEFAULT_CONDITIONS) result.add(d);\n } else {\n result.add(name);\n }\n }\n return result;\n}\n\nfunction isBarePackageSubpath(id: string): boolean {\n if (id.startsWith('.') || path.isAbsolute(id)) {\n return false;\n }\n\n if (id.startsWith('@')) {\n return id.split('/').length > 2;\n }\n\n return id.includes('/');\n}\n\nexport const DefaultModuleImplementation = NativeModule as typeof NativeModule &\n HiddenModuleMembers;\n\n// Supported node builtins based on the modules polyfilled by webpack\n// `true` means module is polyfilled, `false` means module is empty\nconst builtins = {\n assert: true,\n buffer: true,\n child_process: false,\n cluster: false,\n console: true,\n constants: true,\n crypto: true,\n dgram: false,\n dns: false,\n domain: true,\n events: true,\n fs: false,\n http: true,\n https: true,\n module: false,\n net: false,\n os: true,\n path: true,\n punycode: true,\n process: true,\n querystring: true,\n readline: false,\n repl: false,\n stream: true,\n string_decoder: true,\n sys: true,\n timers: true,\n tls: false,\n tty: true,\n url: true,\n util: true,\n vm: true,\n zlib: true,\n};\n\nconst VITE_VIRTUAL_PREFIX = '/@';\nconst REACT_REFRESH_VIRTUAL_ID = '/@react-refresh';\nconst reactRefreshRuntime = {\n createSignatureFunctionForTransform: () => () => {},\n};\n\nconst NOOP = () => {};\n\nconst browserOnlyEvalHintTriggers = [\n 'window is not defined',\n \"evaluating 'window\",\n 'document is not defined',\n \"evaluating 'document\",\n 'navigator is not defined',\n \"evaluating 'navigator\",\n 'self is not defined',\n \"evaluating 'self\",\n];\n\nconst getBrowserOnlyEvalHint = (error: unknown): string | null => {\n const message = error instanceof Error ? error.message : String(error);\n const looksLikeBrowserOnly = browserOnlyEvalHintTriggers.some((trigger) =>\n message.includes(trigger)\n );\n if (!looksLikeBrowserOnly) return null;\n\n return [\n '',\n '[wyw-in-js] Evaluation hint:',\n 'This usually means browser-only code ran during build-time evaluation.',\n 'Move browser-only initialization out of evaluated modules, or mock the import via `importOverrides`.',\n \"Example: importOverrides: { 'msw/browser': { mock: './src/__mocks__/msw-browser.js' } }\",\n ].join('\\n');\n};\n\nconst warnedUnknownImportsByServices = new WeakMap<Services, Set<string>>();\n\nfunction emitWarning(services: Services, message: string) {\n if (services.emitWarning) {\n services.emitWarning(message);\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(message);\n}\n\nfunction getWarnedUnknownImports(services: Services): Set<string> {\n const cached = warnedUnknownImportsByServices.get(services);\n if (cached) {\n return cached;\n }\n\n const created = new Set<string>();\n warnedUnknownImportsByServices.set(services, created);\n return created;\n}\n\nfunction getUncached(cached: string | string[], test: string[]): string[] {\n const cachedSet = new Set(\n typeof cached === 'string' ? cached.split(',') : cached\n );\n\n if (cachedSet.has('*')) {\n return [];\n }\n\n return test.filter((t) => !cachedSet.has(t));\n}\n\nfunction resolve(\n this: { resolveDependency: (id: string) => IEntrypointDependency },\n id: string\n): string {\n const { resolved } = this.resolveDependency(id);\n invariant(resolved, `Unable to resolve \"${id}\"`);\n return resolved;\n}\n\nconst defaultImportLoaders: ImportLoaders = {\n raw: 'raw',\n url: 'url',\n};\n\nexport class Module {\n public readonly callstack: string[] = [];\n\n public readonly debug: Debugger;\n\n public readonly dependencies: string[];\n\n public readonly extensions: string[];\n\n public readonly filename: string;\n\n public id: string;\n\n public readonly idx: string;\n\n public readonly ignored: boolean;\n\n public isEvaluated: boolean = false;\n\n public readonly parentIsIgnored: boolean;\n\n public require: {\n (id: string): unknown;\n ensure: () => void;\n resolve: (id: string) => string;\n } = Object.assign(\n (id: string) => {\n if (id === REACT_REFRESH_VIRTUAL_ID) {\n this.dependencies.push(id);\n this.debug('require', `vite virtual '${id}'`);\n return reactRefreshRuntime;\n }\n\n if (id.startsWith(VITE_VIRTUAL_PREFIX)) {\n this.dependencies.push(id);\n this.debug('require', `vite virtual '${id}'`);\n return {};\n }\n\n if (id in builtins) {\n // The module is in the allowed list of builtin node modules\n // Ideally we should prevent importing them, but webpack polyfills some\n // So we check for the list of polyfills to determine which ones to support\n if (builtins[id as keyof typeof builtins]) {\n this.debug('require', `builtin '${id}'`);\n return require(id);\n }\n\n return null;\n }\n\n // Resolve module id (and filename) relatively to parent module\n const dependency = this.resolveDependency(id);\n if (dependency.resolved === id && !path.isAbsolute(id)) {\n // The module is a builtin node modules, but not in the allowed list\n throw new Error(\n `Unable to import \"${id}\". Importing Node builtins is not supported in the sandbox.`\n );\n }\n\n invariant(\n dependency.resolved,\n `Dependency ${dependency.source} cannot be resolved`\n );\n\n const loaded = this.loadByImportLoaders(id, dependency.resolved);\n if (loaded.handled) {\n this.dependencies.push(id);\n this.debug('require', `${id} -> ${dependency.resolved} (loader)`);\n return loaded.value;\n }\n\n this.dependencies.push(id);\n\n this.debug('require', `${id} -> ${dependency.resolved}`);\n\n const entrypoint = this.getEntrypoint(\n dependency.resolved,\n dependency.only,\n this.debug\n );\n\n if (entrypoint === null) {\n return dependency.resolved;\n }\n\n if (\n entrypoint.evaluated ||\n isSuperSet(entrypoint.evaluatedOnly, dependency.only)\n ) {\n return entrypoint.exports;\n }\n\n const m = this.createChild(entrypoint);\n m.evaluate();\n\n return entrypoint.exports;\n },\n {\n ensure: NOOP,\n resolve: resolve.bind(this),\n }\n );\n\n public resolve = resolve.bind(this);\n\n private cache: TransformCacheCollection;\n\n #entrypointRef: WeakRef<Entrypoint> | Entrypoint;\n\n constructor(\n private services: Services,\n entrypoint: Entrypoint,\n parentModule?: Module,\n private moduleImpl: HiddenModuleMembers = DefaultModuleImplementation\n ) {\n this.cache = services.cache;\n this.#entrypointRef = isFeatureEnabled(\n services.options.pluginOptions.features,\n 'useWeakRefInEval',\n entrypoint.name\n )\n ? new WeakRef(entrypoint)\n : entrypoint;\n this.idx = entrypoint.idx;\n this.id = entrypoint.name;\n this.filename = entrypoint.name;\n this.dependencies = [];\n this.debug = entrypoint.log.extend('module');\n this.parentIsIgnored = parentModule?.ignored ?? false;\n this.ignored = entrypoint.ignored ?? this.parentIsIgnored;\n\n if (parentModule) {\n this.callstack = [entrypoint.name, ...parentModule.callstack];\n } else {\n this.callstack = [entrypoint.name];\n }\n\n this.extensions = services.options.pluginOptions.extensions;\n\n this.debug('init', entrypoint.name);\n }\n\n public get exports() {\n return this.entrypoint.exports;\n }\n\n public set exports(value) {\n this.entrypoint.exports = value;\n\n this.debug('the whole exports was overridden with %O', value);\n }\n\n protected get entrypoint(): Entrypoint {\n const entrypoint =\n this.#entrypointRef instanceof WeakRef\n ? this.#entrypointRef.deref()\n : this.#entrypointRef;\n invariant(entrypoint, `Module ${this.idx} is disposed`);\n return entrypoint;\n }\n\n evaluate(): void {\n const { entrypoint } = this;\n entrypoint.assertTransformed();\n\n const cached = this.cache.get('entrypoints', entrypoint.name)!;\n let evaluatedCreated = false;\n if (!entrypoint.supersededWith) {\n this.cache.add(\n 'entrypoints',\n entrypoint.name,\n entrypoint.createEvaluated()\n );\n evaluatedCreated = true;\n }\n\n const { transformedCode: source } = entrypoint;\n const { pluginOptions } = this.services.options;\n\n if (!source) {\n this.debug(`evaluate`, 'there is nothing to evaluate');\n return;\n }\n\n if (this.isEvaluated) {\n this.debug('evaluate', `is already evaluated`);\n return;\n }\n\n this.debug('evaluate');\n this.debug.extend('source')('%s', source);\n\n this.isEvaluated = true;\n\n const filename = stripQueryAndHash(this.filename);\n\n if (/\\.json$/.test(filename)) {\n // For JSON files, parse it to a JS object similar to Node\n this.exports = JSON.parse(source);\n return;\n }\n\n const { context, teardown } = createVmContext(\n filename,\n pluginOptions.features,\n {\n module: this,\n exports: entrypoint.exports,\n require: this.require,\n __wyw_dynamic_import: async (id: unknown) => this.require(String(id)),\n __dirname: path.dirname(filename),\n },\n pluginOptions.overrideContext\n );\n\n try {\n const script = new vm.Script(\n `(function (exports) { ${source}\\n})(exports);`,\n {\n filename,\n }\n );\n\n script.runInContext(context);\n } catch (e) {\n this.isEvaluated = false;\n if (evaluatedCreated) {\n this.cache.add('entrypoints', entrypoint.name, cached);\n }\n\n if (isUnprocessedEntrypointError(e)) {\n // It will be handled by evalFile scenario\n throw e;\n }\n\n if (e instanceof EvalError) {\n this.debug('%O', e);\n\n throw e;\n }\n\n this.debug('%O\\n%O', e, this.callstack);\n const baseMessage = `${(e as Error).message} in${this.callstack.join(\n '\\n| '\n )}\\n`;\n const hint = getBrowserOnlyEvalHint(e);\n\n throw new EvalError(hint ? `${baseMessage}${hint}\\n` : baseMessage);\n } finally {\n teardown();\n }\n }\n\n getEntrypoint(\n filename: string,\n only: string[],\n log: Debugger\n ): Entrypoint | IEvaluatedEntrypoint | null {\n const strippedFilename = stripQueryAndHash(filename);\n const extension = path.extname(strippedFilename);\n if (extension !== '.json' && !this.extensions.includes(extension)) {\n return null;\n }\n\n let entrypoint = this.cache.get('entrypoints', filename);\n if (entrypoint && isSuperSet(entrypoint.evaluatedOnly ?? [], only)) {\n if (this.cache.checkFreshness(filename, strippedFilename)) {\n entrypoint = undefined;\n }\n\n if (entrypoint) {\n log('✅ file has been already evaluated');\n return entrypoint;\n }\n }\n\n if (entrypoint?.ignored) {\n log(\n '✅ file has been ignored during prepare stage. Original code will be used'\n );\n return entrypoint;\n }\n\n if (this.ignored) {\n log(\n '✅ one of the parent files has been ignored during prepare stage. Original code will be used'\n );\n\n const newEntrypoint = this.entrypoint.createChild(\n filename,\n ['*'],\n fs.readFileSync(strippedFilename, 'utf-8')\n );\n\n if (newEntrypoint === 'loop') {\n const stack = getStack(this.entrypoint);\n throw new Error(\n `Circular dependency detected: ${stack.join(' -> ')} -> ${filename}`\n );\n }\n\n return newEntrypoint;\n }\n\n let uncachedExports: string[] | null = null;\n let reprocessOnly: string[] = only;\n // Requested file can be already prepared for evaluation on the stage 1\n if (only && entrypoint) {\n const evaluatedExports =\n entrypoint.evaluatedOnly?.length !== 0\n ? entrypoint.evaluatedOnly\n : entrypoint.only ?? [];\n uncachedExports = getUncached(evaluatedExports, only);\n if (uncachedExports.length === 0) {\n log('✅ ready for evaluation');\n return entrypoint;\n }\n\n if (entrypoint.evaluatedOnly?.length) {\n reprocessOnly = mergeOnly(evaluatedExports, only);\n }\n\n log(\n '❌ file has been processed during prepare stage but %o is not evaluated yet (evaluated: %o)',\n uncachedExports,\n evaluatedExports\n );\n } else {\n log('❌ file has not been processed during prepare stage');\n }\n\n // If code wasn't extracted from cache, it indicates that we were unable\n // to process some of the imports on stage1. Let's try to reprocess.\n const code = fs.readFileSync(strippedFilename, 'utf-8');\n const newEntrypoint = Entrypoint.createRoot(\n this.services,\n filename,\n reprocessOnly,\n code\n );\n\n if (newEntrypoint.evaluated) {\n log('✅ file has been already evaluated');\n return newEntrypoint;\n }\n\n if (newEntrypoint.ignored) {\n log(\n '✅ file has been ignored during prepare stage. Original code will be used'\n );\n return newEntrypoint;\n }\n\n return newEntrypoint;\n }\n\n private resolveWithConditions(\n id: string,\n parent: { id: string; filename: string; paths: string[] },\n conditions?: Set<string>\n ): string {\n const resolveOptions = conditions ? { conditions } : undefined;\n const shouldRetryWithExtensions =\n conditions &&\n path.extname(id) === '' &&\n (id.startsWith('.') || path.isAbsolute(id) || isBarePackageSubpath(id));\n try {\n return this.moduleImpl._resolveFilename(\n id,\n parent,\n false,\n resolveOptions\n );\n } catch (e: unknown) {\n if (\n shouldRetryWithExtensions &&\n e instanceof Error &&\n (e as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND'\n ) {\n // Extensionless subpath requests (e.g. \"pkg/src/*\" or \"./src/*\") may\n // resolve to extensionless targets via conditional exports. Retry with\n // each known extension, but never rewrite already explicit specifiers.\n for (const ext of this.extensions) {\n try {\n return this.moduleImpl._resolveFilename(\n id + ext,\n parent,\n false,\n resolveOptions\n );\n } catch {\n // try next extension\n }\n }\n }\n throw e;\n }\n }\n\n resolveDependency = (id: string): IEntrypointDependency => {\n const cached = this.entrypoint.getDependency(id);\n invariant(!(cached instanceof Promise), 'Dependency is not resolved yet');\n\n if (cached) {\n return cached;\n }\n\n if (!this.ignored) {\n this.debug(\n '❌ import has not been resolved during prepare stage. Fallback to Node.js resolver'\n );\n }\n\n const extensions = this.moduleImpl._extensions;\n const added: string[] = [];\n\n try {\n // Check for supported extensions\n this.extensions.forEach((ext) => {\n if (ext in extensions) {\n return;\n }\n\n // When an extension is not supported, add it\n // And keep track of it to clean it up after resolving\n // Use noop for the transform function since we handle it\n extensions[ext] = NOOP;\n added.push(ext);\n });\n\n const { filename } = this;\n const strippedId = stripQueryAndHash(id);\n\n const parent = {\n id: filename,\n filename,\n paths: this.moduleImpl._nodeModulePaths(path.dirname(filename)),\n };\n const { conditionNames } = this.services.options.pluginOptions;\n const conditions = conditionNames?.length\n ? expandConditions(conditionNames)\n : undefined;\n\n let resolved = this.resolveWithConditions(strippedId, parent, conditions);\n\n const isFileSpecifier =\n strippedId.startsWith('.') || path.isAbsolute(strippedId);\n\n if (\n isFileSpecifier &&\n path.extname(strippedId) === '' &&\n resolved.endsWith('.cjs') &&\n fs.existsSync(`${resolved.slice(0, -4)}.js`)\n ) {\n // When both `.cjs` and `.js` exist for an extensionless specifier, the\n // resolver may pick `.cjs` depending on the environment/extensions.\n // Prefer `.js` to keep resolved paths stable (e.g. importOverrides keys).\n resolved = `${resolved.slice(0, -4)}.js`;\n }\n\n const { root } = this.services.options;\n const keyInfo = toImportKey({\n source: id,\n resolved,\n root,\n });\n\n const override = getImportOverride(\n this.services.options.pluginOptions.importOverrides,\n keyInfo.key\n );\n\n const policy = override?.unknown ?? (override?.mock ? 'allow' : 'warn');\n const shouldWarn = !this.ignored && policy === 'warn';\n\n let finalResolved = resolved;\n if (override?.mock) {\n try {\n finalResolved = resolveMockSpecifier({\n mock: override.mock,\n importer: filename,\n root,\n stack: this.callstack,\n });\n } catch (e) {\n const errorMessage = String((e as Error)?.message ?? e);\n throw new Error(\n `[wyw-in-js] Failed to resolve import mock for \"${keyInfo.key}\" (${id} from ${filename}): ${errorMessage}`\n );\n }\n }\n\n if (policy === 'error') {\n throw new Error(\n [\n `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,\n ``,\n `importer: ${filename}`,\n `source: ${id}`,\n `resolved: ${resolved}`,\n override?.mock\n ? `mock: ${override.mock} -> ${finalResolved}`\n : ``,\n ``,\n `callstack:`,\n ...this.callstack.map((item) => ` ${item}`),\n ``,\n `config key: ${keyInfo.key}`,\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n const warnedUnknownImports = getWarnedUnknownImports(this.services);\n\n if (shouldWarn && !warnedUnknownImports.has(keyInfo.key)) {\n warnedUnknownImports.add(keyInfo.key);\n emitWarning(\n this.services,\n [\n `[wyw-in-js] Unknown import reached during eval (Node resolver fallback)`,\n ``,\n `importer: ${filename}`,\n `source: ${id}`,\n `resolved: ${resolved}`,\n override?.mock\n ? `mock: ${override.mock} -> ${finalResolved}`\n : ``,\n ``,\n `callstack:`,\n ...this.callstack.map((item) => ` ${item}`),\n ``,\n `config key: ${keyInfo.key}`,\n `hint: add { importOverrides: { ${JSON.stringify(\n keyInfo.key\n )}: { unknown: 'allow' } } } to silence warnings, or use { mock } / { noShake: true } overrides.`,\n ]\n .filter(Boolean)\n .join('\\n')\n );\n }\n\n return {\n source: id,\n only: applyImportOverrideToOnly(['*'], override),\n resolved: finalResolved,\n };\n } finally {\n // Cleanup the extensions we added to restore previous behaviour\n added.forEach((ext) => delete extensions[ext]);\n }\n };\n\n protected createChild(entrypoint: Entrypoint): Module {\n return new Module(this.services, entrypoint, this, this.moduleImpl);\n }\n\n private loadByImportLoaders(\n request: string,\n resolved: string\n ): { handled: boolean; value: unknown } {\n const { pluginOptions } = this.services.options;\n const importLoaders =\n pluginOptions.importLoaders === undefined\n ? defaultImportLoaders\n : { ...defaultImportLoaders, ...pluginOptions.importLoaders };\n\n const { query, hash } = parseRequest(request);\n if (!query) return { handled: false, value: undefined };\n\n const params = new URLSearchParams(query);\n const matchedKey = Array.from(params.keys()).find(\n (key) => importLoaders[key] !== undefined && importLoaders[key] !== false\n );\n\n if (!matchedKey) return { handled: false, value: undefined };\n\n const loader = importLoaders[matchedKey];\n\n const filename = stripQueryAndHash(resolved);\n const importer = stripQueryAndHash(this.filename);\n const importerDir = path.dirname(importer);\n\n const toUrl = () => {\n const relative = path\n .relative(importerDir, filename)\n .replace(/\\\\/g, path.posix.sep);\n\n if (relative.startsWith('.') || path.isAbsolute(relative)) {\n return relative;\n }\n\n return `./${relative}`;\n };\n\n const readFile = () => fs.readFileSync(filename, 'utf-8');\n\n const context: ImportLoaderContext = {\n importer,\n request,\n resolved,\n filename,\n query,\n hash,\n emitWarning: (message) => emitWarning(this.services, message),\n readFile,\n toUrl,\n };\n\n if (loader === 'raw') {\n return { handled: true, value: context.readFile() };\n }\n\n if (loader === 'url') {\n return { handled: true, value: context.toUrl() };\n }\n\n if (typeof loader === 'function') {\n return { handled: true, value: loader(context) };\n }\n\n return { handled: false, value: undefined };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,EAAE,MAAM,IAAI;AACnB,OAAOC,YAAY,MAAM,QAAQ;AACjC,OAAOC,IAAI,MAAM,MAAM;AACvB,OAAOC,EAAE,MAAM,IAAI;AAEnB,SAASC,SAAS,QAAQ,cAAc;AAExC,SACEC,gBAAgB,QAIX,mBAAmB;AAE1B,OAAO,0BAA0B;AAEjC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SACEC,QAAQ,EACRC,UAAU,EACVC,SAAS,QACJ,gCAAgC;AAGvC,SAASC,4BAA4B,QAAQ,gDAAgD;AAE7F,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,oBAAoB,EACpBC,WAAW,QACN,yBAAyB;AAChC,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,sBAAsB;AACtE,SAASC,eAAe,QAAQ,sBAAsB;AAatD,MAAMC,sBAAsB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAU;AAEtE,SAASC,gBAAgBA,CAACC,cAAwB,EAAe;EAC/D,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAAS,CAAC;EAChC,KAAK,MAAMC,IAAI,IAAIH,cAAc,EAAE;IACjC,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E,CAAC;IACrD;IAEA,IAAIP,MAAM,KAAK,KAAK,EAAE;MACpB,OAAO;QAAE9G,OAAO,EAAE,IAAI;QAAEC,KAAK,EAAEoC,OAAO,CAAC2E,KAAK,CAAC;MAAE,CAAC;IAClD;IAEA,IAAI,OAAOF,MAAM,KAAK,UAAU,EAAE;MAChC,OAAO;QAAE9G,OAAO,EAAE,IAAI;QAAEC,KAAK,EAAE6G,MAAM,CAACzE,OAAO;MAAE,CAAC;IAClD;IAEA,OAAO;MAAErC,OAAO,EAAE,KAAK;MAAEC,KAAK,EAAEqD;IAAU,CAAC;EAC7C;AACF","ignoreList":[]}
@@ -8,6 +8,7 @@ import { BaseAction } from './actions/BaseAction';
8
8
  import { UnprocessedEntrypointError } from './actions/UnprocessedEntrypointError';
9
9
  import { stripQueryAndHash } from '../utils/parseRequest';
10
10
  const EMPTY_FILE = '=== empty file ===';
11
+ const DEFAULT_ACTION_CONTEXT = Symbol('defaultActionContext');
11
12
  function hasLoop(name, parent, processed = []) {
12
13
  if (parent.name === name || processed.includes(parent.name)) {
13
14
  return true;
@@ -183,16 +184,20 @@ export class Entrypoint extends BaseEntrypoint {
183
184
  beginProcessing() {
184
185
  this.#isProcessing = true;
185
186
  }
186
- createAction(actionType, data, abortSignal = null) {
187
+ createAction(actionType, data, abortSignal = null, actionContext = DEFAULT_ACTION_CONTEXT) {
187
188
  if (!this.actionsCache.has(actionType)) {
188
189
  this.actionsCache.set(actionType, new Map());
189
190
  }
190
- const cache = this.actionsCache.get(actionType);
191
+ const contexts = this.actionsCache.get(actionType);
192
+ if (!contexts.has(actionContext)) {
193
+ contexts.set(actionContext, new Map());
194
+ }
195
+ const cache = contexts.get(actionContext);
191
196
  const cached = cache.get(data);
192
197
  if (cached && !cached.abortSignal?.aborted) {
193
198
  return cached;
194
199
  }
195
- const newAction = new BaseAction(actionType, this.services, this, data, abortSignal);
200
+ const newAction = new BaseAction(actionType, this.services, this, data, abortSignal, actionContext);
196
201
  cache.set(data, newAction);
197
202
  this.services.eventEmitter.entrypointEvent(this.seqId, {
198
203
  type: 'actionCreated',