From ce1fda302e6a7da377e2eb554acdb5f2e6f0e0c4 Mon Sep 17 00:00:00 2001 From: jayree Date: Mon, 26 Jun 2023 15:41:05 +0200 Subject: [PATCH] chore: remove process.browser dependency --- src/models/FileSystem.js | 10 +++++----- webpack.config.cjs | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/models/FileSystem.js b/src/models/FileSystem.js index 864860058..c863b12a2 100644 --- a/src/models/FileSystem.js +++ b/src/models/FileSystem.js @@ -1,3 +1,5 @@ +import fs from 'fs' + import pify from 'pify' import { compareStrings } from '../utils/compareStrings.js' @@ -223,11 +225,9 @@ export class FileSystem { try { const stats = await this._lstat(filename) // For non-browser (local) scenarios regular git 'add' command might be used to write the index. Therefore we need to have the exact nanoseconds (see. normalizeStats.js SecondsNanoseconds ). - if (!process.browser) { - const statsNs = await this._lstat(filename, { bigint: true }) - stats.mtimeNs = statsNs.mtimeNs - stats.ctimeNs = statsNs.ctimeNs - } + const statsNs = await fs.promises.lstat(filename, { bigint: true }) + stats.mtimeNs = statsNs.mtimeNs + stats.ctimeNs = statsNs.ctimeNs return stats } catch (err) { if (err.code === 'ENOENT') { diff --git a/webpack.config.cjs b/webpack.config.cjs index 068bc17c4..a6dbdea27 100644 --- a/webpack.config.cjs +++ b/webpack.config.cjs @@ -6,6 +6,9 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') module.exports = [ { target: 'webworker', + node: { + fs: 'empty', + }, entry: { index: './src/index.js', 'internal-apis': './src/internal-apis.js',