Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kettek/snowpack-plugin-selective-import-to-require
A selective import to require snowpack plugin.
https://github.com/kettek/snowpack-plugin-selective-import-to-require
Last synced: 19 days ago
JSON representation
A selective import to require snowpack plugin.
- Host: GitHub
- URL: https://github.com/kettek/snowpack-plugin-selective-import-to-require
- Owner: kettek
- License: mpl-2.0
- Created: 2021-02-18T12:07:02.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-18T23:55:26.000Z (almost 4 years ago)
- Last Synced: 2024-12-01T07:42:00.436Z (about 1 month ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# snowpack-plugin-selective-import-to-require
Selectively convert `import` calls into `require` calls. Useful for running snowpack with Electron.```
npm install --save-dev snowpack-plugin-selective-import-to-require
``````js
// snowpack.config.json
module.exports = {
"plugins": [
[
"snowpack-plugin-selective-import-to-require",
{
"modules": ["os", "child_process"],
"types": ['.js'],
}
]
]
}
```#### Plugin Options
| Name | Type | Description |
| :----------------- | :--------- | :---------- |
| `modules` | `string[]` | An array of module names to match against, such as `['os', 'child_process']`.
| `types` | `string[]` | (optional) By default, this plugin matches against `['.js']`. Provide an array if you need to match other extensions.#### Match Built-in Node Modules
It may be convenient to match all built-in node modules.```
npm install builtin-modules --save-dev
``````js
// snowpack.config.json
const builtinModules = require('builtin-modules')module.exports = {
"plugins": [
[
"snowpack-plugin-selective-import-to-require",
{
"modules": builtinModules,
"types": ['.js'],
}
]
],
"packageOptions": {
"external": builtinModules
},
}```