{"id":24983679,"url":"https://github.com/posthtml/esm","last_synced_at":"2025-10-08T02:49:36.102Z","repository":{"id":57137733,"uuid":"118679761","full_name":"posthtml/esm","owner":"posthtml","description":"webpack HTML Module Helpers","archived":false,"fork":false,"pushed_at":"2018-01-23T23:09:19.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T21:06:05.744Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-01-23T22:40:27.000Z","updated_at":"2018-01-24T10:56:49.000Z","dependencies_parsed_at":"2022-08-22T20:31:51.517Z","dependency_job_id":null,"html_url":"https://github.com/posthtml/esm","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fesm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fesm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fesm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fesm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/esm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245458719,"owners_count":20618697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-04T09:20:16.523Z","updated_at":"2025-10-08T02:49:31.050Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","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\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"110\" height=\"200\" title=\"PostHTML Plugin\" src=\"http://michael-ciniawsky.github.io/postcss-load-plugins/logo.svg\"\u003e\n  \u003cimg width=\"160\" height=\"200\" title=\"PostHTML\" src=\"http://posthtml.github.io/posthtml/logo.svg\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"110\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eESM Plugin\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003e ⚠️ 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\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm i -D @posthtml/esm\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n```js\nconst posthtml = require('posthtml')\nconst { urls, imports } = require('@posthtml/esm')\n\nconst html = `\n\u003cimg src=\"path/to/url.png\"\u003e\n\u003cimport src=\"path/to/import.html\"\u003e\u003c/import\u003e\n`\nposthtml([ urls(), imports() ])\n  .process(html, { from: './src/index.html' })\n  .then((result) =\u003e {\n    result.html\n    result.messages\n  })\n```  \n\n**result.html**\n```html\n\u003cimg src=\"${HTML__URL__0}\"\u003e\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\u003ch2 align=\"center\"\u003eOptions\u003c/h2\u003e\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\u003c{String} -\u003e {Boolean}\u003e}`\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\u003c{String} -\u003e {Boolean}\u003e}`\n\n```js\nimports({\n  import (url) {\n    return /filter/.test(url)\n  }\n})\n```\n\n\u003ch2 align=\"center\"\u003eMaintainer\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n   \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg width=\"150\" height=\"150\"\n     src=\"https://github.com/michael-ciniawsky.png?v=3\u0026s=150\"\u003e\n      \u003cbr /\u003e\n      \u003ca href=\"https://github.com/michael-ciniawsky\"\u003eMichael Ciniawsky\u003c/a\u003e\n    \u003c/td\u003e\n   \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\u003ch2 align=\"center\"\u003eContributors\u003c/h2\u003e\n\n\u003c!-- \u003ctable\u003e\n  \u003ctbody\u003e\n   \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cimg width=\"150\" height=\"150\"\n      src=\"https://github.com/${user}.png?v=3\u0026s=150\"\u003e\n      \u003cbr /\u003e\n      \u003ca href=\"https://github.com/${user}\"\u003e${name}\u003c/a\u003e\n    \u003c/td\u003e\n   \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e --\u003e\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fesm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fesm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fesm/lists"}