Skip to content

Commit ce80818

Browse files
authored
Do not use hard coded path separator and clean ups (#457)
1 parent 4d2e618 commit ce80818

File tree

2 files changed

+1
-71
lines changed

2 files changed

+1
-71
lines changed

dashboard-plugin/FederationDashboardPlugin.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ class FederationDashboardPlugin {
264264

265265
if (graphData) {
266266
const dashData = (this._dashData = JSON.stringify(graphData));
267-
this.writeStatsFiles(stats, dashData);
268267
if (this._options.dashboardURL && !this._options.nextjs) {
269268
this.postDashboardData(dashData).catch((err) => {
270269
if (err) {
@@ -475,74 +474,6 @@ class FederationDashboardPlugin {
475474
return Array.from(directReasons);
476475
}
477476

478-
// This is no longer needed - can be deleted or used for refactoring the asset emitter
479-
writeStatsFiles(stats, dashData) {
480-
if (this._options.filename) {
481-
const hashPath = path.join(stats.outputPath, this._options.filename);
482-
if (!fs.existsSync(stats.outputPath)) {
483-
fs.mkdirSync(stats.outputPath);
484-
}
485-
fs.writeFile(hashPath, dashData, { encoding: "utf-8" }, () => {});
486-
}
487-
if (this._options.debug) {
488-
console.log(
489-
path.join(stats.outputPath, this.FederationPluginOptions.filename)
490-
);
491-
}
492-
const file = fs.readFileSync(
493-
path.join(stats.outputPath, this.FederationPluginOptions.filename)
494-
);
495-
const { version } = JSON.parse(dashData);
496-
if (!version) {
497-
throw new Error("no version provided, cannot version remote");
498-
}
499-
if (this._options.debug) {
500-
console.log(
501-
path.join(
502-
stats.outputPath,
503-
version,
504-
this.FederationPluginOptions.filename
505-
)
506-
);
507-
}
508-
fs.mkdir(
509-
path.join(stats.outputPath, version),
510-
{ recursive: true },
511-
(err) => {
512-
if (err) throw err;
513-
fs.writeFile(
514-
path.join(
515-
stats.outputPath,
516-
version,
517-
this.FederationPluginOptions.filename
518-
),
519-
file,
520-
(err) => {
521-
if (this._options.debug) {
522-
console.trace(err);
523-
console.log(
524-
"wrote versioned remote",
525-
path.join(
526-
stats.outputPath,
527-
version,
528-
this.FederationPluginOptions.filename
529-
)
530-
);
531-
}
532-
}
533-
);
534-
}
535-
);
536-
537-
const statsPath = path.join(stats.outputPath, "stats.json");
538-
fs.writeFile(
539-
statsPath,
540-
JSON.stringify(stats),
541-
{ encoding: "utf-8" },
542-
() => {}
543-
);
544-
}
545-
546477
async postDashboardData(dashData) {
547478
if (!this._options.dashboardURL) {
548479
return Promise.resolve();

dashboard-plugin/convertToGraph.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ const convertToGraph = (
9696
});
9797
} else if (nameForCondition && nameForCondition.includes("node_modules")) {
9898
const contextArray = nameForCondition.split(path.sep);
99-
const afterModule = nameForCondition.split("node_modules/");
99+
const afterModule = nameForCondition.split("node_modules" + path.sep);
100100

101101
const search = afterModule[1] && afterModule[1].startsWith("@") ? 3 : 2;
102102
contextArray.splice(contextArray.indexOf("node_modules") + search);
103103

104104
const context = contextArray.join(path.sep);
105-
const npmModule = contextArray[contextArray.indexOf("node_modules") + 1];
106105

107106
const packageJsonFile = path.join(context, "package.json");
108107
const packageJson = JSON.parse(fs.readFileSync(packageJsonFile, "UTF-8"));

0 commit comments

Comments
 (0)