Closed
Description
When i build my svelte app by webpack with cache-loader
introduced, i've got an error:
typeError: stats.mtime.getTime is not a function
at FS.stat (/Users/xxx/svelte-webpack/node_modules/cache-loader/dist/index.js:114:33)
at process.nextTick (/Users/xxx/svelte-webpack/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:85:15)
at process._tickCallback (internal/process/next_tick.js:61:11)
...
And then i print out the stats
object into the terminal to find out what the 'mtime' key is, the logs are as below:
log => Stats {
dev: 16777220,
mode: 33188,
nlink: 1,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4194304,
ino: 15306205,
size: 51,
blocks: 8,
atimeMs: 1593482967553.3503,
mtimeMs: 499162500000,
ctimeMs: 1592617381679.1177,
birthtimeMs: 499162500000,
atime: 2020-06-30T02:09:27.553Z,
mtime: 1985-10-26T08:15:00.000Z,
ctime: 2020-06-20T01:43:01.679Z,
birthtime: 1985-10-26T08:15:00.000Z }
log => VirtualStats {
dev: 8675309,
nlink: 0,
uid: 1000,
gid: 1000,
rdev: 0,
blksize: 4096,
ino: 45000000,
mode: 33188,
size: 1219,
blocks: 0,
atime: 1593483324657,
mtime: 1593483324657,
ctime: 1593483324657,
birthtime: 1593483324657 }
According to these, we can see the mtime
is not a date object in VirtualStats
which is provided in svelte-loader/lib/virtual.js
:
// Starts in line 49.
VirtualModulesPlugin.prototype.writeModule = function(filePath, contents) {
var len = contents ? contents.length : 0;
var time = Date.now(); // Here it is, it's just a time stamp, not a date object.
var stats = new VirtualStats({
// ...
mtime: time,
// ...
});
// ...
};
But webpack cache-loader
treats the mtime
as a date object, and will invoke its getTime
method, that's the problem!
Metadata
Metadata
Assignees
Labels
No labels