From b9cca90c7dfe6fad6c5d0864e2ae21de6a385685 Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 4 Apr 2024 16:14:29 -0700 Subject: [PATCH 1/2] Use require.resolve to resolve relative to kolibri-tools --- .../kolibri-tools/lib/webpack.config.base.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/kolibri-tools/lib/webpack.config.base.js b/packages/kolibri-tools/lib/webpack.config.base.js index eb9b709681..553a2e1106 100644 --- a/packages/kolibri-tools/lib/webpack.config.base.js +++ b/packages/kolibri-tools/lib/webpack.config.base.js @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); const { VueLoaderPlugin } = require('vue-loader'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const CssMinimizerPlugin = require('css-minimizer-webpack-plugin'); @@ -17,28 +17,33 @@ module.exports = ({ mode = 'development', hot = false, cache = false, transpile const base_dir = path.join(__dirname, '..'); const postCSSLoader = { - loader: 'postcss-loader', + loader: require.resolve('postcss-loader'), options: { postcssOptions: { - plugins: [['autoprefixer']], + plugins: [[require.resolve('autoprefixer')]], }, sourceMap: !production, }, }; const cssLoader = { - loader: 'css-loader', + loader: require.resolve('css-loader'), options: { sourceMap: !production }, }; // for scss blocks - const sassLoaders = [cssInsertionLoader, cssLoader, postCSSLoader, 'sass-loader']; + const sassLoaders = [ + cssInsertionLoader, + cssLoader, + postCSSLoader, + require.resolve('sass-loader'), + ]; const rules = [ // Transpilation and code loading rules { test: /\.vue$/, - loader: 'vue-loader', + loader: require.resolve('vue-loader'), options: { compilerOptions: { preserveWhitespace: false, @@ -70,7 +75,7 @@ module.exports = ({ mode = 'development', hot = false, cache = false, transpile if (transpile) { rules.push({ test: /\.(js|mjs)$/, - loader: 'babel-loader', + loader: require.resolve('babel-loader'), exclude: [ // From: https://webpack.js.org/loaders/babel-loader/#exclude-libraries-that-should-not-be-transpiled // \\ for Windows, / for macOS and Linux @@ -143,7 +148,7 @@ module.exports = ({ mode = 'development', hot = false, cache = false, transpile 'process.server': JSON.stringify(false), }), new webpack.ProvidePlugin({ - process: 'process/browser', + process: require.resolve('process/browser'), }), ], devtool: production ? 'source-map' : 'cheap-module-source-map', From ec46a67ecd064241ca0e4b7fb2bdd44f0eb3b74c Mon Sep 17 00:00:00 2001 From: Blaine Jester Date: Thu, 4 Apr 2024 16:17:38 -0700 Subject: [PATCH 2/2] Use node protocol for node.js APIs --- packages/kolibri-tools/lib/alias_import_resolver.js | 2 +- packages/kolibri-tools/lib/apiSpecExportTools.js | 4 ++-- packages/kolibri-tools/lib/clean.js | 4 ++-- packages/kolibri-tools/lib/cli.js | 4 ++-- packages/kolibri-tools/lib/compress.js | 4 ++-- packages/kolibri-tools/lib/ensureDist.js | 4 ++-- packages/kolibri-tools/lib/lint.js | 4 ++-- packages/kolibri-tools/lib/read_webpack_json.js | 6 +++--- packages/kolibri-tools/lib/version.js | 4 ++-- packages/kolibri-tools/lib/webpack.config.plugin.js | 2 +- packages/kolibri-tools/lib/webpackBundleTracker.js | 6 +++--- packages/kolibri-tools/lib/webpackRtlPlugin.js | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/kolibri-tools/lib/alias_import_resolver.js b/packages/kolibri-tools/lib/alias_import_resolver.js index 2b764bac78..dbd55e4f8c 100644 --- a/packages/kolibri-tools/lib/alias_import_resolver.js +++ b/packages/kolibri-tools/lib/alias_import_resolver.js @@ -1,4 +1,4 @@ -var path = require('path'); +var path = require('node:path'); var resolve = require('resolve'); var coreAliases = require('./apiSpecExportTools').coreAliases(); var coreExternals = require('./apiSpecExportTools').coreExternals(); diff --git a/packages/kolibri-tools/lib/apiSpecExportTools.js b/packages/kolibri-tools/lib/apiSpecExportTools.js index c0279f8994..c3a5ebd64d 100644 --- a/packages/kolibri-tools/lib/apiSpecExportTools.js +++ b/packages/kolibri-tools/lib/apiSpecExportTools.js @@ -1,6 +1,6 @@ /* eslint-disable */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const resolve = require('resolve'); const espree = require('espree'); const escodegen = require('escodegen'); diff --git a/packages/kolibri-tools/lib/clean.js b/packages/kolibri-tools/lib/clean.js index 8197c0481a..fcbeea1194 100644 --- a/packages/kolibri-tools/lib/clean.js +++ b/packages/kolibri-tools/lib/clean.js @@ -1,5 +1,5 @@ -var path = require('path'); -var fs = require('fs'); +var path = require('node:path'); +var fs = require('node:fs'); var logging = require('./logging'); var deleteRecursive = function(p) { diff --git a/packages/kolibri-tools/lib/cli.js b/packages/kolibri-tools/lib/cli.js index 4a098a2d41..675565ba2c 100755 --- a/packages/kolibri-tools/lib/cli.js +++ b/packages/kolibri-tools/lib/cli.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const program = require('commander'); const checkVersion = require('check-node-version'); const ini = require('ini'); diff --git a/packages/kolibri-tools/lib/compress.js b/packages/kolibri-tools/lib/compress.js index b4aaa471c5..1f82874cf8 100644 --- a/packages/kolibri-tools/lib/compress.js +++ b/packages/kolibri-tools/lib/compress.js @@ -1,5 +1,5 @@ -const { constants, createGzip } = require('zlib'); -const { pipeline } = require('stream'); +const { constants, createGzip } = require('node:zlib'); +const { pipeline } = require('node:stream'); const { createReadStream, createWriteStream } = require('fs'); const logger = require('./logging'); diff --git a/packages/kolibri-tools/lib/ensureDist.js b/packages/kolibri-tools/lib/ensureDist.js index a3395bb6b8..a981491d48 100644 --- a/packages/kolibri-tools/lib/ensureDist.js +++ b/packages/kolibri-tools/lib/ensureDist.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); function ensureDist() { fs.mkdirSync(path.resolve(__dirname, '../dist'), { recursive: true }); diff --git a/packages/kolibri-tools/lib/lint.js b/packages/kolibri-tools/lib/lint.js index 2f9aa389ee..e0b24cb21c 100755 --- a/packages/kolibri-tools/lib/lint.js +++ b/packages/kolibri-tools/lib/lint.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const prettier = require('prettier'); const compiler = require('vue-template-compiler'); const ESLintCLIEngine = require('eslint').CLIEngine; diff --git a/packages/kolibri-tools/lib/read_webpack_json.js b/packages/kolibri-tools/lib/read_webpack_json.js index a466221951..b0d139e43d 100644 --- a/packages/kolibri-tools/lib/read_webpack_json.js +++ b/packages/kolibri-tools/lib/read_webpack_json.js @@ -1,6 +1,6 @@ -const fs = require('fs'); -const execSync = require('child_process').execSync; -const path = require('path'); +const fs = require('node:fs'); +const execSync = require('node:child_process').execSync; +const path = require('node:path'); const temp = require('temp').track(); const webpack_json = path.resolve(path.dirname(__filename), './webpack_json.py'); diff --git a/packages/kolibri-tools/lib/version.js b/packages/kolibri-tools/lib/version.js index 1a9472ad77..471e112e81 100644 --- a/packages/kolibri-tools/lib/version.js +++ b/packages/kolibri-tools/lib/version.js @@ -1,5 +1,5 @@ -const fs = require('fs'); -const execSync = require('child_process').execSync; +const fs = require('node:fs'); +const execSync = require('node:child_process').execSync; const temp = require('temp').track(); const readlineSync = require('readline-sync'); const semver = require('semver'); diff --git a/packages/kolibri-tools/lib/webpack.config.plugin.js b/packages/kolibri-tools/lib/webpack.config.plugin.js index f0a51e7181..4cd9ccb7ca 100644 --- a/packages/kolibri-tools/lib/webpack.config.plugin.js +++ b/packages/kolibri-tools/lib/webpack.config.plugin.js @@ -7,7 +7,7 @@ * to add test specific features. */ -const path = require('path'); +const path = require('node:path'); const webpack = require('webpack'); const { merge } = require('webpack-merge'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); diff --git a/packages/kolibri-tools/lib/webpackBundleTracker.js b/packages/kolibri-tools/lib/webpackBundleTracker.js index 9816af3162..8243aa7b1f 100644 --- a/packages/kolibri-tools/lib/webpackBundleTracker.js +++ b/packages/kolibri-tools/lib/webpackBundleTracker.js @@ -20,9 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -const path = require('path'); -const fs = require('fs'); -const crypto = require('crypto'); +const path = require('node:path'); +const fs = require('node:fs'); +const crypto = require('node:crypto'); const defaults = require('lodash/defaults'); const assign = require('lodash/assign'); diff --git a/packages/kolibri-tools/lib/webpackRtlPlugin.js b/packages/kolibri-tools/lib/webpackRtlPlugin.js index 80a53e5749..8ff1f942ae 100644 --- a/packages/kolibri-tools/lib/webpackRtlPlugin.js +++ b/packages/kolibri-tools/lib/webpackRtlPlugin.js @@ -13,7 +13,7 @@ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // Vendored and simplified from https://github.com/romainberger/webpack-rtl-plugin/blob/master/src/index.js -const path = require('path'); +const path = require('node:path'); const rtlcss = require('rtlcss'); const webpack = require('webpack');