{"_id":"@posthtml/esm","_rev":"325973","name":"@posthtml/esm","description":"ESM Plugin for PostHTML","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"scrum","email":"scrum@list.ru"},{"name":"voischev","email":"voischev-ivan@ya.ru"}],"time":{"modified":"2021-06-07T02:44:40.000Z","created":"2018-01-23T23:09:25.350Z","1.0.0":"2018-01-23T23:09:25.350Z"},"users":{},"author":{"name":"Michael Ciniawsky","email":"michael.ciniawsky@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/posthtml/esm.git"},"versions":{"1.0.0":{"name":"@posthtml/esm","version":"1.0.0","description":"ESM Plugin for PostHTML","license":"MIT","engines":{"node":">= 4"},"main":"lib","files":["lib"],"scripts":{"lint":"standard --env jest","test":"jest --verbose --coverage","docs":"jsdoc2md lib/*.js > PLUGIN.md","clean":"rm -rf coverage","release":"standard-version"},"dependencies":{},"devDependencies":{"jest":"^22.0.0","jsdoc-to-markdown":"^3.0.0","posthtml":"^0.11.0","standard":"^11.0.0-beta.0","standard-version":"4.0.0"},"keywords":["esm","url","import","include","posthtml","posthtmlplugin"],"author":{"name":"Michael Ciniawsky","email":"michael.ciniawsky@gmail.com"},"contributors":[],"bugs":{"url":"https://github.com/posthtml/esm/issues"},"homepage":"https://github.com/posthtml/esm#readme","repository":{"type":"git","url":"git+https://github.com/posthtml/esm.git"},"gitHead":"b6e159dbcd5f87e2e677bd5f2fcadd8e0bb6a339","_id":"@posthtml/esm@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.2.0","_npmUser":{"name":"michael-ciniawsky","email":"michael.ciniawsky@gmail.com"},"dist":{"shasum":"09bcb28a02438dcee22ad1970ca1d85a000ae0cf","size":3872,"noattachment":false,"key":"/@posthtml/esm/-/@posthtml/esm-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@posthtml/esm/download/@posthtml/esm-1.0.0.tgz"},"maintainers":[{"name":"scrum","email":"scrum@list.ru"},{"name":"voischev","email":"voischev-ivan@ya.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/esm-1.0.0.tgz_1516748964457_0.34774269186891615"},"directories":{},"publish_time":1516748965350,"_hasShrinkwrap":false,"_cnpm_publish_time":1516748965350}},"readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![code style][style]][style-url]\n[![chat][chat]][chat-url]\n\n<div align=\"center\">\n  <img width=\"110\" height=\"200\" title=\"PostHTML Plugin\" src=\"http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg\">\n  <img width=\"160\" height=\"200\" title=\"PostHTML\" src=\"http://posthtml.github.io/posthtml/logo.svg\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"110\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n  <h1>ESM Plugin</h1>\n</div>\n\n> ⚠️ These plugins are **helpers** mainly for `html-loader` to extract URL's and make them separate module request as ES2015 Module Imports and are not intended for general usage with `posthtml`. Other bundlers targeting ES2015 Modules (e.g Parcel, Rollup) may utilize them aswell, but usage besides `webpack` is currently untested. Feel free to open an issue if your integration\nrequires changes\n\n<h2 align=\"center\">Install</h2>\n\n```bash\nnpm i -D @posthtml/esm\n```\n\n<h2 align=\"center\">Usage</h2>\n\n```js\nconst posthtml = require('posthtml')\nconst { urls, imports } = require('@posthtml/esm')\n\nconst html = `\n<img src=\"path/to/url.png\">\n<import src=\"path/to/import.html\"></import>\n`\nposthtml([ urls(), imports() ])\n  .process(html, { from: './src/index.html' })\n  .then((result) => {\n    result.html\n    result.messages\n  })\n```  \n\n**result.html**\n```html\n<img src=\"${HTML__URL__0}\">\n${HTML__IMPORT__0}\n```\n\n**result.messages**\n```js\n[\n  {\n    type: 'import',\n    plugin: '@posthtml/esm',\n    url: 'path/to/url.png',\n    name: `HTML__URL__0`,\n    import () {\n      return `import ${this.name} from '${this.url}';\\n`\n    }\n  },\n  {\n    type: 'import',\n    plugin: '@posthtml/esm',\n    url: 'path/to/import.html',\n    name: `HTML__IMPORT__0`,\n    import () {\n      return `import ${this.name} from '${this.url}';\\n`\n    }\n  }\n]\n```\n\n<h2 align=\"center\">Options</h2>\n\n### `urls`\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**[`url`](#urls)**|`{RegExp\\|Function}`|`''`|Filter URL's|\n\n#### `{RegExp}`\n\n```js\nurls({\n  url: /filter/\n})\n```\n\n#### `{Function<{String} -> {Boolean}>}`\n\n```js\nurls({\n  url (url) {\n    return /filter/.test(url)\n  }\n})\n```\n\n### `imports`\n\n|Name|Type|Default|Description|\n|:--:|:--:|:-----:|:----------|\n|**[`import`](#imports)**|`{RegExp\\|Function}`|`''`|Filter Import URL's|\n|**[`template`](#imports)**|`{String}`|`''`|Placeholder for HTML Templates|\n\n#### `{RegExp}`\n\n```js\nimports({\n  import: /filter/\n})\n```\n\n#### `{Function<{String} -> {Boolean}>}`\n\n```js\nimports({\n  import (url) {\n    return /filter/.test(url)\n  }\n})\n```\n\n<h2 align=\"center\">Maintainer</h2>\n\n<table>\n  <tbody>\n   <tr>\n    <td align=\"center\">\n      <img width=\"150\" height=\"150\"\n     src=\"https://github.com/michael-ciniawsky.png?v=3&s=150\">\n      <br />\n      <a href=\"https://github.com/michael-ciniawsky\">Michael Ciniawsky</a>\n    </td>\n   </tr>\n  <tbody>\n</table>\n\n<h2 align=\"center\">Contributors</h2>\n\n<!-- <table>\n  <tbody>\n   <tr>\n    <td align=\"center\">\n      <img width=\"150\" height=\"150\"\n      src=\"https://github.com/${user}.png?v=3&s=150\">\n      <br />\n      <a href=\"https://github.com/${user}\">${name}</a>\n    </td>\n   </tr>\n  <tbody>\n</table> -->\n\n\n[npm]: https://img.shields.io/npm/v/@posthtml/esm.svg\n[npm-url]: https://npmjs.com/package/@posthtml/esm\n\n[node]: https://img.shields.io/node/v/@posthtml/esm.svg\n[node-url]: https://nodejs.org/\n\n[deps]: https://david-dm.org/posthtml/esm.svg\n[deps-url]: https://david-dm.org/posthtml/esm\n\n[tests]: http://img.shields.io/travis/posthtml/esm.svg\n[tests-url]: https://travis-ci.org/posthtml/esm\n\n[cover]: https://coveralls.io/repos/github/posthtml/esm/badge.svg\n[cover-url]: https://coveralls.io/github/posthtml/esm\n\n[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg\n[style-url]: http://standardjs.com/\n\n[chat]: https://badges.gitter.im/posthtml/posthtml.svg\n[chat-url]: https://gitter.im/posthtml/posthtml\n","_attachments":{},"homepage":"https://github.com/posthtml/esm#readme","bugs":{"url":"https://github.com/posthtml/esm/issues"},"license":"MIT"}