From 671c005243065d24e806b2604a65d2f4bfbc52d9 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Mon, 17 Nov 2025 09:09:34 -0700 Subject: [PATCH 1/2] Linting/formatting --- tasks/preprocess.js | 61 +++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/tasks/preprocess.js b/tasks/preprocess.js index 302628090ec..85163e0ba1c 100644 --- a/tasks/preprocess.js +++ b/tasks/preprocess.js @@ -16,25 +16,32 @@ updateVersion(constants.pathToPlotlyVersion); // convert scss to css to js and static css file function makeBuildCSS() { - sass.render({ - file: constants.pathToSCSS, - outputStyle: 'compressed' - }, function(err, result) { - if(err) throw err; + sass.render( + { + file: constants.pathToSCSS, + outputStyle: 'compressed' + }, + function (err, result) { + if (err) throw err; - // To support application with strict CSP where styles cannot be inlined, - // build a static CSS file that can be included into such applications. - var staticCSS = String(result.css); - for(var k in mapBoxGLStyleRules) { - staticCSS = addAdditionalCSSRules(staticCSS, '.js-plotly-plot .plotly .mapboxgl-' + k, mapBoxGLStyleRules[k]); - } - fs.writeFile(constants.pathToCSSDist, staticCSS, function(err) { - if(err) throw err; - }); + // To support application with strict CSP where styles cannot be inlined, + // build a static CSS file that can be included into such applications. + var staticCSS = String(result.css); + for (var k in mapBoxGLStyleRules) { + staticCSS = addAdditionalCSSRules( + staticCSS, + '.js-plotly-plot .plotly .mapboxgl-' + k, + mapBoxGLStyleRules[k] + ); + } + fs.writeFile(constants.pathToCSSDist, staticCSS, function (err) { + if (err) throw err; + }); - // css to js to be inlined - pullCSS(String(result.css), constants.pathToCSSBuild); - }); + // css to js to be inlined + pullCSS(String(result.css), constants.pathToCSSBuild); + } + ); } function addAdditionalCSSRules(staticStyleString, selector, style) { @@ -44,7 +51,7 @@ function addAdditionalCSSRules(staticStyleString, selector, style) { function exposePartsInLib() { var obj = {}; - var insert = function(name, folder) { + var insert = function (name, folder) { obj[name] = folder + '/' + name; }; @@ -52,7 +59,7 @@ function exposePartsInLib() { insert('calendars', 'src/components'); - constants.allTraces.forEach(function(k) { + constants.allTraces.forEach(function (k) { insert(k, 'src/traces'); }); @@ -60,24 +67,14 @@ function exposePartsInLib() { } function writeLibFiles(obj) { - for(var name in obj) { + for (var name in obj) { common.writeFile( path.join(constants.pathToLib, name + '.js'), - [ - '\'use strict\';', - '', - 'module.exports = require(\'../' + obj[name] + '\');', - '' - ].join('\n') + ["'use strict';", '', "module.exports = require('../" + obj[name] + "');", ''].join('\n') ); } } function copyTopojsonFiles() { - fs.copy( - constants.pathToTopojsonSrc, - constants.pathToTopojsonDist, - { clobber: true }, - common.throwOnError - ); + fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist, { clobber: true }, common.throwOnError); } From 5b85b5d9eb30df93c11af37c6f88c1fef946efd1 Mon Sep 17 00:00:00 2001 From: Cameron DeCoster Date: Mon, 17 Nov 2025 09:10:31 -0700 Subject: [PATCH 2/2] Omit ISO country codes list when copying topojson to dist folder --- tasks/preprocess.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tasks/preprocess.js b/tasks/preprocess.js index 85163e0ba1c..8753e7c160b 100644 --- a/tasks/preprocess.js +++ b/tasks/preprocess.js @@ -76,5 +76,14 @@ function writeLibFiles(obj) { } function copyTopojsonFiles() { - fs.copy(constants.pathToTopojsonSrc, constants.pathToTopojsonDist, { clobber: true }, common.throwOnError); + const FILES_TO_EXCLUDE = ['country_names_iso_codes.json']; + fs.copy( + constants.pathToTopojsonSrc, + constants.pathToTopojsonDist, + { + clobber: true, + filter: (filePath) => !FILES_TO_EXCLUDE.includes(path.basename(filePath)) + }, + common.throwOnError + ); }