Skip to content

Commit

Permalink
Provide an option to configure ES module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Sailer committed Aug 10, 2021
1 parent 0adf94f commit c374796
Show file tree
Hide file tree
Showing 10 changed files with 14,979 additions and 6 deletions.
15 changes: 15 additions & 0 deletions packages/font-config-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ module.exports = {
],
};
```
### Enable CommonJS module syntax
By default the `font-config-webpack-plugin` uses the CommonJS modules syntax (`require` statements).
You can enable a ES module syntax (`import` statements) syntax using: `esModule: true` in the options.

For more information see [file-loader documentation](https://v4.webpack.js.org/loaders/file-loader/#esmodule)
```js
const FontConfigWebpackPlugin = require('font-config-webpack-plugin');
module.exports = {
plugins: [
new FontConfigWebpackPlugin({
esModule: true
}),
],
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports = module.exports = (options) => ({
loader: require.resolve('file-loader'),
options: {
name: options.name,
esModule: options.esModule,
},
},
],
Expand Down
7,473 changes: 7,473 additions & 0 deletions packages/font-config-webpack-plugin/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
* Plugin Options
* @typedef {{
mode?: 'production' | 'development'
name: string,
esModule?: boolean
name: string
}} FontConfigWebpackPluginOptions */

'use strict';
/**
* @type {FontConfigWebpackPluginOptions}
*/
const defaultOptions = { name: 'static/media/[name].[hash:8].[ext]' };
const defaultOptions = { name: 'static/media/[name].[hash:8].[ext]', esModule: false };

class FontConfigWebpackPlugin {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('FontConfigWebpackPlugin standalone', () => {
});

it('should return an instance with the options assigned to it', () => {
const options = { name: '[hash]-[name].[ext]' };
const options = { name: '[hash]-[name].[ext]', esModule: false };
const instance = new FontConfigWebpackPlugin(options);

expect(instance.options).toEqual(options);
Expand Down
16 changes: 16 additions & 0 deletions packages/image-config-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,19 @@ module.exports = {
],
};
```
### Enable CommonJS module syntax
By default the `image-config-webpack-plugin` uses the CommonJS modules syntax (`require` statements).
You can enable a ES module syntax (`import` statements) syntax using: `esModule: true` in the options.

For more information see [file-loader documentation](https://v4.webpack.js.org/loaders/file-loader/#esmodule)

```js
const ImageConfigWebpackPlugin = require('image-config-webpack-plugin');
module.exports = {
plugins: [
new ImageConfigWebpackPlugin({
esModule: true
}),
],
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports = module.exports = (options) => ({
loader: require.resolve('file-loader'),
options: {
name: options.name,
esModule: options.esModule,
},
},
],
Expand Down
Loading

0 comments on commit c374796

Please sign in to comment.