diff --git a/esm.js b/esm.js index c5fbfc4c4..010f2515e 100644 --- a/esm.js +++ b/esm.js @@ -171,9 +171,9 @@ if (cachePath !== "") { circular: 0, code: null, codeWithTDZ: null, + ctime: -1, filename: null, firstAwaitOutsideFunction: null, - mtime: -1, scriptData, sourceType: 1, transforms: 0, diff --git a/src/caching-compiler.js b/src/caching-compiler.js index 3f971a1be..e84e6cfbc 100644 --- a/src/caching-compiler.js +++ b/src/caching-compiler.js @@ -65,9 +65,9 @@ function init() { circular: 0, code: null, codeWithTDZ: null, + ctime: -1, filename: null, firstAwaitOutsideFunction: null, - mtime: -1, scriptData: null, sourceType: SOURCE_TYPE_SCRIPT, transforms: 0, @@ -90,7 +90,7 @@ function init() { } } - result.mtime = +meta[3] + result.ctime = +meta[3] result.sourceType = +meta[4] result.transforms = +meta[2] } @@ -123,8 +123,8 @@ function init() { return result } + result.ctime = options.ctime result.filename = options.filename - result.mtime = options.mtime return result } @@ -293,9 +293,9 @@ function init() { if (compileData !== null) { const { + ctime, filename, firstAwaitOutsideFunction, - mtime, sourceType, transforms } = compileData @@ -313,7 +313,7 @@ function init() { if (transforms !== 0) { meta.push( transforms, - mtime, + ctime, sourceType, deflatedFirstAwaitOutsideFunction, relative(cachePath, filename) @@ -322,7 +322,7 @@ function init() { } else { meta.push( transforms, - mtime, + ctime, sourceType, deflatedFirstAwaitOutsideFunction, relative(cachePath, filename), diff --git a/src/compiler.js b/src/compiler.js index f3aa084b4..9647b0693 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -63,9 +63,9 @@ function init() { circular: 0, code, codeWithTDZ: null, + ctime: -1, filename: null, firstAwaitOutsideFunction: null, - mtime: -1, scriptData: null, sourceType: SOURCE_TYPE_SCRIPT, transforms: 0, diff --git a/src/entry.js b/src/entry.js index 50dfbaf98..4557c162e 100644 --- a/src/entry.js +++ b/src/entry.js @@ -15,9 +15,9 @@ import encodeId from "./util/encode-id.js" import errors from "./errors.js" import getCacheName from "./util/get-cache-name.js" import getCacheStateHash from "./util/get-cache-state-hash.js" +import getCtime from "./fs/get-ctime.js" import getModuleDirname from "./util/get-module-dirname.js" import getModuleName from "./util/get-module-name.js" -import getMtime from "./fs/get-mtime.js" import getPrototypeOf from "./util/get-prototype-of.js" import has from "./util/has.js" import isCalledFromStrictCode from "./util/is-called-from-strict-code.js" @@ -155,7 +155,7 @@ class Entry { setDeferred(this, "cacheName", () => { const pkg = this.package - return getCacheName(this.mtime, { + return getCacheName(this.ctime, { cachePath: pkg.cachePath, filename: this.filename, packageOptions: pkg.options @@ -188,9 +188,9 @@ class Entry { return createImmutableNamespaceProxy(this, this._completeNamespace) }) - // The mtime of the module. - setDeferred(this, "mtime", () => { - return getMtime(this.filename) + // The ctime of the module. + setDeferred(this, "ctime", () => { + return getCtime(this.filename) }) // The mutable namespace object that non-ESM importers receive. diff --git a/src/fs/get-mtime.js b/src/fs/get-ctime.js similarity index 57% rename from src/fs/get-mtime.js rename to src/fs/get-ctime.js index 332ce2fad..b99fabd5b 100644 --- a/src/fs/get-mtime.js +++ b/src/fs/get-ctime.js @@ -4,28 +4,26 @@ import shared from "../shared.js" import statSync from "../fs/stat-sync.js" function init() { - const { round } = Math - - function getMtime(filename) { + function getCtime(filename) { if (typeof filename === "string") { try { const stat = statSync(filename) - const { mtimeMs } = stat + const { ctimeMs } = stat // Add 0.5 to avoid rounding down. // https://github.com/nodejs/node/pull/12607 - return typeof mtimeMs === "number" - ? round(mtimeMs + 0.5) - : GenericDate.getTime(stat.mtime) + return typeof ctimeMs === "number" + ? Math.round(ctimeMs + 0.5) + : GenericDate.getTime(stat.ctime) } catch {} } return -1 } - return getMtime + return getCtime } export default shared.inited - ? shared.module.fsGetMtime - : shared.module.fsGetMtime = init() + ? shared.module.fsGetCtime + : shared.module.fsGetCtime = init() diff --git a/src/module/internal/compile.js b/src/module/internal/compile.js index 8876d7af2..f171ff081 100644 --- a/src/module/internal/compile.js +++ b/src/module/internal/compile.js @@ -133,9 +133,9 @@ function compile(caller, entry, content, filename, fallback) { circular: 0, code: null, codeWithTDZ: null, + ctime: -1, filename: null, firstAwaitOutsideFunction: null, - mtime: -1, scriptData: null, sourceType: hint, transforms: 0, @@ -165,9 +165,9 @@ function compile(caller, entry, content, filename, fallback) { cachePath: pkg.cachePath, cjsPaths, cjsVars, + ctime: entry.ctime, filename, hint, - mtime: entry.mtime, runtimeName: entry.runtimeName, sourceType, topLevelReturn