Skip to content

Commit

Permalink
Merge pull request #12052 from bjester/pnpm-peeer
Browse files Browse the repository at this point in the history
Resolve webpack loaders and dependencies relative to kolibri-tools
  • Loading branch information
rtibbles authored Apr 9, 2024
2 parents c446419 + ec46a67 commit 421626f
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/kolibri-tools/lib/alias_import_resolver.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/apiSpecExportTools.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/clean.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/cli.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/compress.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/ensureDist.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/lint.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/kolibri-tools/lib/read_webpack_json.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/kolibri-tools/lib/version.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
21 changes: 13 additions & 8 deletions packages/kolibri-tools/lib/webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/kolibri-tools/lib/webpack.config.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions packages/kolibri-tools/lib/webpackBundleTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/kolibri-tools/lib/webpackRtlPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit 421626f

Please sign in to comment.