From ae8de8031dc713d888c5d72c068c509646f48f2c Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Tue, 15 Oct 2024 15:46:02 +0200 Subject: [PATCH] Revert "Fix duplicate queries.json file generation" This reverts commit 165f3fb3a158cfef70365e3fac77bf7ce77aa309. Reverted because the package deployed to npm was broken because of this. A proper fix will land in #162. --- bin/generate.js | 3 --- plugins/MoveFilePlugin.js | 25 ------------------------- webpack.config.js | 19 ++++--------------- 3 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 plugins/MoveFilePlugin.js diff --git a/bin/generate.js b/bin/generate.js index dcb5a31b..201f2181 100755 --- a/bin/generate.js +++ b/bin/generate.js @@ -60,9 +60,6 @@ if (args.h || args.help || args._.length > 1) { // Override the baseURL in the webpack config webpackConfig.baseURL.replace = baseURL; - // Override the buildContext in the webpack config - webpackConfig.buildContext.dir = destinationPath; - for (const entry of webpackConfig) { entry.mode = mode; if (entry.output) { diff --git a/plugins/MoveFilePlugin.js b/plugins/MoveFilePlugin.js deleted file mode 100644 index 6da8023e..00000000 --- a/plugins/MoveFilePlugin.js +++ /dev/null @@ -1,25 +0,0 @@ -const fs = require('fs'); - -class MoveFilePlugin { - - /** - * Create a new instance of the MoveFilePlugin. - * This plugin expects two functions as arguments, because the paths will be different at runtime. - * @param getSource method to retrieve the source file path - * @param getDestination method to retrieve the destination file path - */ - constructor(getSource, getDestination) { - this.getSource = getSource; - this.getDestination = getDestination; - } - - apply(compiler) { - compiler.hooks.afterEmit.tap('MoveFilePlugin', (compilation) => { - if (fs.existsSync(this.getSource())) { - fs.renameSync(this.getSource(), this.getDestination()); - } - }); - } -} - -module.exports = MoveFilePlugin; diff --git a/webpack.config.js b/webpack.config.js index 42ed7e5c..15aa2d05 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,5 @@ const path = require('path'); const webpack = require('webpack'); -const MoveFilePlugin = require('./plugins/MoveFilePlugin'); // First check if we can load Comunica form cwd, if not, fallback to the default let pathToComunica; @@ -14,7 +13,7 @@ catch { comunicaOverride = false; } -// Make this an object, so we can mutate it from the top level of the config +// Make this an object so we can mutate it from the top level of the config // and have the options propagated to the plugins const baseURL = { search: '<%= baseURL %>', @@ -24,12 +23,6 @@ const baseURL = { flags: 'g' } -// Make this an object, so we can mutate it from the top level of the config -// and have the options propagated to the plugins -const buildContext = { - dir: 'build', -} - module.exports = [ { entry: [ @@ -48,6 +41,7 @@ module.exports = [ path.join(__dirname, './images/sparql.png'), path.join(__dirname, './favicon.ico'), path.join(__dirname, './solid-client-id.jsonld'), + path.join(process.cwd(), './queries.json'), ], output: { filename: 'scripts/ldf-client-ui.min.js', @@ -59,11 +53,6 @@ module.exports = [ jQuery: path.join(__dirname, '/deps/jquery-2.1.0.js'), }), new webpack.NormalModuleReplacementPlugin(/^comunica-packagejson$/, (process.platform === 'win32' ? '' : '!!json-loader!') + path.join(pathToComunica, '../../package.json')), - // Include the generated queries.json file by moving it from the current working directory (where it was generated) to the build path. - new MoveFilePlugin( - () => path.join(process.cwd(), 'queries.json'), - () => path.join(__dirname, `${buildContext.dir}/queries.json`) - ), ], module: { rules: [ @@ -166,6 +155,6 @@ module.exports = [ }, ]; -// Export the baseURL and buildContext objects, so we can mutate it in the generate script +// Export the baseURL object so we can mutated it +// in the generate script module.exports.baseURL = baseURL; -module.exports.buildContext = buildContext;