From 7efc4cdc1de4bbb970a28b2bd10636f9aad88b1c Mon Sep 17 00:00:00 2001 From: Ben Heidemann <56122437+bcheidemann@users.noreply.github.com> Date: Mon, 15 Nov 2021 16:05:39 +0000 Subject: [PATCH] Fix Issue #790 (#793) * fix: make wepback plugin available from filer/webpack * deprecate accessing FilerWebpackPlugin through index.js * docs: update documentation to reflect changes to FilerWebpackPlugin * docs: fix typo --- README.md | 17 ++++++++++++++--- src/index.js | 9 +++++++++ webpack/index.js | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 webpack/index.js diff --git a/README.md b/README.md index 67a76a6..c5fc5c4 100644 --- a/README.md +++ b/README.md @@ -63,17 +63,28 @@ your webpack config: ```javascript // webpack.config.js -var filer = require('filer'); +var { FilerWebpackPlugin } = require('filer/webpack'); module.exports = { plugins: [ - new filer.FilerWebpackPlugin(), + new FilerWebpackPlugin(), ], } ``` +--- +**NOTE** + +Previously it was recommended to access the `FilerWebpackPlugin` class by importing the main filer module. This was depracated due [this issue](https://github.com/filerjs/filer/issues/790). For anyone using ***filer version 1.3.1 or earlier***, please import the plugin class like this: + +```javascript +var FilerWebpackPlugin = require('filer/src/webpack-plugin'); +``` + +--- + You can then import the node.js [fs](http://nodejs.org/api/fs.html) and [path](http://nodejs.org/api/path.html) -modules as normal and FilerWebpackPlugin will ensure that webpack will resolve references to these modules to +modules as normal and `FilerWebpackPlugin` will ensure that webpack will resolve references to these modules to the appropriate filer shims. You will then be able to use these modules as normal (with the exception of the synchronous fs methods e.g. `mkdirSync()`). diff --git a/src/index.js b/src/index.js index 8a77c73..0a25e25 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,15 @@ module.exports = Filer = { path: require('./path.js'), Errors: require('./errors.js'), Shell: require('./shell/shell.js'), + /** + * @deprecated Importing filer from your webpack config is not recommended. + * + * The filer `FilerWebpackPlugin` class is exposed directly. + * + * ``` + * const { FilerWebpackPlugin } = require('filer/webpack'); + * ``` + */ FilerWebpackPlugin: require('./webpack-plugin'), }; diff --git a/webpack/index.js b/webpack/index.js new file mode 100644 index 0000000..7b353cc --- /dev/null +++ b/webpack/index.js @@ -0,0 +1,3 @@ +module.exports = { + FilerWebpackPlugin: require('../src/webpack-plugin'), +};