{"name":"rollup-plugin-transform-tagged-template","version":"0.0.3","description":"Apply transformations on static contents of tagged template string literals","homepage":"https://github.com/notlmn/rollup-plugin-transform-tagged-template#readme","repository":{"type":"git","url":"git+https://github.com/notlmn/rollup-plugin-transform-tagged-template.git"},"main":"./cjs/index.js","scripts":{"cjs":"ucjs esm cjs","build":"npm run cjs","lint":"xo esm/","test":"npm run lint && npm run build && rollup -c test/rollup.config.js"},"keywords":["rollup","plugin","template string","template literal","tagged template string literal"],"author":{"name":"Laxman Damera"},"license":"MIT","devDependencies":{"rollup":"^2.18.0","ucjs":"^0.1.1","xo":"^0.32.0"},"module":"./esm/index.js","type":"module","exports":{"import":"./esm/index.js","default":"./cjs/index.js"},"dependencies":{"@babel/generator":"^7.10.3","@babel/parser":"^7.10.3","@babel/traverse":"^7.10.3"},"xo":{"rules":{"no-unused-vars":"off"}},"gitHead":"e7972a1122887ece41e4cd325ad92979767e3cc8","bugs":{"url":"https://github.com/notlmn/rollup-plugin-transform-tagged-template/issues"},"_id":"rollup-plugin-transform-tagged-template@0.0.3","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-IY8JwVTZxwOqQU1B1lqBAfvj0PXgy60pe480mgfs5CCbwytBMQCSrG1eHnD1o8+JCl+5gHdKK5wNXnFngCHxkw==","shasum":"b18df7931dbc43984a1c81ee2edcc266a9f6844e","tarball":"http://registry-npm.ywwl.com/rollup-plugin-transform-tagged-template/download/rollup-plugin-transform-tagged-template-0.0.3.tgz","fileCount":9,"unpackedSize":10047,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfAB3zCRA9TVsSAnZWagAAPSUP+waGhwd8o3DsNNFJpdG+\nFtE+I8MSnFV1p1BjrNXYyRdFOC1DNZ7xOD1VoHdvMo2JayPH28S8ldRVd+0U\nnnCHQPzbVgDOmIocO9KHQVYdQJjnAsAX8tMu27NUwZKvYtRtFUOhndN3iY83\n2ueseb7WAvO6svnsEk3XrqPSY+8HxVjlhm4S1EbBBYrd1b9A0jCGiaUo7n/i\n6wyHrsf3NXzlLWOhWuZNw4jluESuwrLEaxVo+cA6wofHinlK4ZyxyGUYvDRD\nb7IHVfExuwM2islTEvKgRv2VQSENAg84bGnC2AFbTOcQqMLRIW/TQhteMePH\ns5n3ci0ieBlJv/BkE7G+ms7P1BniesOG3h7mmfKhjwMWH0SYX+Z+6/hiSQV6\nXjgPYCci58mPeMMWjHnGEcIOHMHQ1uV58Nmn8ztXRoup89MmmY/7onXYBrgv\noaly6w7wOmZTkcAeSPD+M11pjLhYQtEAs6htYYAL8Xd98V0rtK2kU+zI1g2d\ncY/CkghBnpettkkFjRDB/hR/imDnUzTIia+kIWfpXPKmbRF+y2n9DmHkFR8h\nnQUZEHTRoG1qOhhKnr4Ssu+CimkEhgc8cT15zMQgR7E2sTr1CJD/mkHJ35bO\ndyIyBVtadCP3EaW+iTAP6vY7M1nslUln6HBdiTsuqYRMCqxaw1H11uNnXAPM\nL05e\r\n=ty92\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0sqjAuEcCK3OtY+yz5RZ/dHET115Bx/hx9V6aK9KMsAIhAKjZgKqONP0vwTAx2YUj3XyGwHGsgcDne0WRgntXnX7Y"}],"size":3825,"noattachment":false,"key":"/rollup-plugin-transform-tagged-template/-/rollup-plugin-transform-tagged-template-0.0.3.tgz"},"maintainers":[{"name":"lmn","email":"notlmn@outlook.com"}],"_npmUser":{"name":"lmn","email":"notlmn@outlook.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-transform-tagged-template_0.0.3_1593843186745_0.5364068352757871"},"_hasShrinkwrap":false,"readme":"# rollup-plugin-transform-tagged-template\n\n> Apply transformations on contents of [tagged template string literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), aka. template strings aka. template literals.\n\n[![npm](https://img.shields.io/npm/v/rollup-plugin-transform-tagged-template)](https://www.npmjs.com/package/rollup-plugin-transform-tagged-template)\n\n## Usage\n\n``` js\n// rollup.config.js\nimport transformTaggedTemplate from 'rollup-plugin-transform-tagged-template';\n\nexport default {\n\tinput: 'test.js',\n\tplugins: [\n\t\ttransformTaggedTemplate({\n\t\t\ttagsToProcess: ['css'],\n\t\t\ttransformer(data) {\n\t\t\t\t// Spaces before and after these characters\n\t\t\t\tdata = data.replace(/\\s*([{}()>~+=^$:!;])\\s*/gm, '$1');\n\n\t\t\t\t// Spaces only after these characters\n\t\t\t\tdata = data.replace(/([\",\\[\\]])\\s+/gm, '$1');\n\n\t\t\t\t// You only need one space consequent in CSS\n\t\t\t\tdata = data.replace(/\\s{2,}/gm, ' ');\n\n\t\t\t\treturn data.trim();\n\t\t\t}\n\t\t})\n\t],\n\toutput: {\n\t\tfile: 'build.js'\n\t}\n};\n```\n\n## API\n\n### `tagsToProces: string[]`\n\nRefers to the tag names that are to be processed. In the example above, `css` is the tag that is processed.\n\nExample: `tagsToProcess: ['handleCSS']` would target the following template literal.\n\n``` js\nconst result = handleCSS`\n\t:host {\n\t\tdisplay: block;\n\t}\n`;\n```\n\n### `transformer: (string) => string`\n\nDoes what it says, one-to-one mapping of part of a template string.\n\n> This could sometimes be only part of what you are expecting to get as argument. See example below.\n\nExample:\n\n``` js\n// code.js\nconst declaration = handleCSS`color: #212121;`;\nconst result = handleCSS`\n\t:host {\n\t\tdisplay: block;\n\t\t${declaration}\n\t}\n`;\n```\n\n``` js\n// rollup.js\n\t// ...\n\tplugins: [\n\t\ttransformTaggedTemplate({\n\t\t\ttagsToProcess: ['handleCSS'],\n\t\t\ttransformer(data) {\n                console.log(data);\n\t\t\t\treturn data;\n\t\t\t}\n\t\t})\n\t],\n\t// ...\n\n// Output\n[\n\t'color: #212121;',\n\t'\\n\\t:host {\\n\\t\\tdisplay: block;\\n\\t\\t',\n\t'\\n\\t\\t}\\n',\n]\n```\n\n### `parserOptions: object`\n\nConfig options to pass to the Babel parser.\n\n> Babel Parser options may be needed depending on how your project is structured. See [Babel parser options](https://babeljs.io/docs/en/babel-parser#options) for all available options.\n\nExample:\n\n```js\n// rollup.js\n\t// ...\n\tplugins: [\n\t\ttransformTaggedTemplate({\n\t\t\tparserOptions: {\n\t\t\t\tsourceType: \"module\", // treat files as ES6 modules\n\t\t\t\tplugins: [\n\t\t\t\t\t\"typescript\", // parse the file as TypeScript\n\t\t\t\t\t[\n\t\t\t\t\t\t\"decorators\", // use decorators proposal plugin\n\t\t\t\t\t\t{ decoratorsBeforeExport: true }\n\t\t\t\t\t]\n\t\t\t\t]\n\t\t\t}\n\t\t})\n\t],\n\t// ...\n```\n\n## Related\n\n- [rollup-plugin-minify-tagged-css-template](https://github.com/notlmn/rollup-plugin-minify-tagged-css-template) - Rollup plugin to minify CSS content of tagged template string literals.\n\n## License\n\n[MIT](license) &copy; Laxman Damera\n","publish_time":1593843186911,"_cnpm_publish_time":1593843186911,"dist-tags":{"latest":"0.0.3"}}