* 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
This commit is contained in:
Ben Heidemann 2021-11-15 16:05:39 +00:00 committed by GitHub
parent 4112d072b5
commit 7efc4cdc1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -63,17 +63,28 @@ your webpack config:
```javascript ```javascript
// webpack.config.js // webpack.config.js
var filer = require('filer'); var { FilerWebpackPlugin } = require('filer/webpack');
module.exports = { module.exports = {
plugins: [ 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) 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 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()`). synchronous fs methods e.g. `mkdirSync()`).

View File

@ -9,6 +9,15 @@ module.exports = Filer = {
path: require('./path.js'), path: require('./path.js'),
Errors: require('./errors.js'), Errors: require('./errors.js'),
Shell: require('./shell/shell.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'), FilerWebpackPlugin: require('./webpack-plugin'),
}; };

3
webpack/index.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
FilerWebpackPlugin: require('../src/webpack-plugin'),
};