Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukeed/webpack-modules
Handle `.mjs` files correctly within webpack
https://github.com/lukeed/webpack-modules
Last synced: about 1 month ago
JSON representation
Handle `.mjs` files correctly within webpack
- Host: GitHub
- URL: https://github.com/lukeed/webpack-modules
- Owner: lukeed
- License: mit
- Created: 2019-02-28T20:02:15.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-28T20:05:22.000Z (almost 6 years ago)
- Last Synced: 2024-10-14T01:10:51.413Z (about 2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 71
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome - webpack-modules - Handle `.mjs` files correctly within webpack (JavaScript)
README
# webpack-modules
> Handle `.mjs` files correctly
Because webpack does it wrong and won't fix it.
Without this plugin, `.mjs` files will **only** consider other `.mjs` files as ESM. It completely disregards any `.js` files in the ESM format, forcing them to seen & treated as CommonJS modules (despite their contents). _([comment](https://github.com/reactjs/react-transition-group/pull/77))_
Additionally, without this plugin, `.mjs` files do not follow the same [`resolve.mainFields`](https://webpack.js.org/configuration/resolve/#resolvemainfields) sequence that's defined in your main configuration. _([comment](https://github.com/webpack/webpack/issues/6796#issuecomment-374980347))_
## Usage
The plugin takes no options. Simply require it and invoke like any other plugin~
```js
// webpack.config.js
const WebpackModules = require('webpack-modules');module.exports = {
// ...
plugins: [
new WebpackModules()
]
}
```## Credits
Thank you to [@ForsakenHarmony](https://github.com/ForsakenHarmony) who did the research and legwork as part of [`preact-cli`](https://github.com/developit/preact-cli) – via [this](https://github.com/developit/preact-cli/pull/741/files) and [that](https://github.com/developit/preact-cli/pull/746/files).
## License
MIT © [Luke Edwards](https://lukeed.com)