{"id":13775314,"url":"https://github.com/aMarCruz/rollup-plugin-jscc","last_synced_at":"2025-05-11T07:32:25.120Z","repository":{"id":46211122,"uuid":"67324152","full_name":"aMarCruz/rollup-plugin-jscc","owner":"aMarCruz","description":"Conditional compilation and compile-time variable replacement for Rollup","archived":false,"fork":false,"pushed_at":"2021-11-06T14:36:46.000Z","size":152,"stargazers_count":58,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T00:43:49.437Z","etag":null,"topics":["es6","javascript","jscc","jspreproc","preprocessor","rollup","rollup-plugin","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aMarCruz.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":null,"security":null,"support":null}},"created_at":"2016-09-04T03:44:28.000Z","updated_at":"2024-10-28T14:47:49.000Z","dependencies_parsed_at":"2022-08-28T02:11:58.792Z","dependency_job_id":null,"html_url":"https://github.com/aMarCruz/rollup-plugin-jscc","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-jscc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-jscc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-jscc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aMarCruz%2Frollup-plugin-jscc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aMarCruz","download_url":"https://codeload.github.com/aMarCruz/rollup-plugin-jscc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224849601,"owners_count":17380124,"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":["es6","javascript","jscc","jspreproc","preprocessor","rollup","rollup-plugin","typescript"],"created_at":"2024-08-03T17:01:36.765Z","updated_at":"2024-11-17T10:30:56.242Z","avatar_url":"https://github.com/aMarCruz.png","language":"JavaScript","funding_links":["https://ko-fi.com/C0C7LF7I"],"categories":["Plugins"],"sub_categories":["Workflow"],"readme":"# rollup-plugin-jscc\n\n\u003c!-- prettier-ignore-start --\u003e\n[![npm Version][npm-badge]][npm-url]\n[![Build Status][build-badge]][build-url]\n[![AppVeyor Status][wbuild-badge]][wbuild-url]\n[![Maintainability][climate-badge]][climate-url]\n[![Test coverage][codecov-badge]][codecov-url]\n[![License][license-badge]][license-url]\n\u003c!-- prettier-ignore-end --\u003e\n\nConditional compilation and compile-time variable replacement for [Rollup](http://rollupjs.org/).\n\nrollup-plugin-jscc is **not** a transpiler, it is a wrapper of [jscc](https://github.com/aMarCruz/jscc), a tiny and powerful, language agnostic file preprocessor that uses JavaScript to transform text based on expressions at compile time.\n\nWith jscc, you have:\n\n- Conditional inclusion/exclusion of blocks, based on compile-time variables\\*\n- Compile-time variables with all the power of JavaScript expressions\n- Replacement of variables in the sources, by its value _at compile-time_\n- Sourcemap support, useful for JavaScript sources.\n- TypeScript v3 definitions\n\n\\* This feature allows you the conditional declaration of ES6 imports (See the [example](#example)).\n\nSince jscc is a preprocessor, rollup-plugin-jscc is implemented as a _file loader_, so it runs before any transpiler and is invisible to them. This behavior allows you to use it in a wide range of file types but, if necessary, it can be used as a Rollup _transformer_ instead of a loader.\n\n_**NOTE**_\n\nThe removal of non-jscc comments is not included, but you can use [rollup-plugin-cleanup](https://github.com/aMarCruz/rollup-plugin-cleanup), which brings compaction and normalization of lines in addition to the conditional removal of JS comments.\n\n## Support my Work\n\nI'm a full-stack developer with more than 20 year of experience and I try to share most of my work for free and help others, but this takes a significant amount of time, effort and coffee so, if you like my work, please consider...\n\n[\u003cimg src=\"https://amarcruz.github.io/images/kofi_blue.png\" height=\"36\" title=\"Support Me on Ko-fi\" /\u003e][kofi-url]\n\nOf course, feedback, PRs, and stars are also welcome 🙃\n\nThanks for your support!\n\n## Install\n\n```bash\nnpm i rollup-plugin-jscc -D\n# or\nyarn add rollup-plugin-jscc -D\n```\n\nrollup-plugin-jscc requires rollup v2.0 and node.js v10.12 or later.\n\n### Usage\n\nrollup.config.js\n\n```js\nimport { rollup } from 'rollup'\nimport jscc from 'rollup-plugin-jscc'\n\nexport default {\n  input: 'src/main.js',\n  plugins: [\n    jscc({\n      values: { _APPNAME: 'My App', _DEBUG: 1 },\n    }),\n  ],\n  //...other options\n}\n```\n\nin your source:\n\n```js\n/*#if _DEBUG\nimport mylib from 'mylib-debug';\n//#else */\nimport mylib from 'mylib'\n//#endif\n\nmylib.log('Starting $_APPNAME v$_VERSION...')\n```\n\noutput:\n\n```js\nimport mylib from 'mylib-debug'\n\nmylib.log('Starting My App v1.0.0...')\n```\n\nThat's it.\n\n\\* jscc has two predefined memvars: `_FILE` and `_VERSION`, in addition to giving access to the environment variables through the nodejs [`proccess.env`](https://nodejs.org/api/process.html#process_process_env) object.\n\n## Options\n\nPlain JavaScript object, with all properties optional.\n\n| Name | Type | Description |\n| --- | --- | --- |\n| asloader | boolean | If `false`, run the plugin as a `transformer`, otherwise run as `loader` (the default). |\n| escapeQuotes | string | String with the type of quotes to escape in the output of strings: 'single', 'double' or 'both'.\u003cbr\u003e**Default** nothing. |\n| keepLines | boolean | Preserves the empty lines of directives and blocks that were removed.\u003cbr\u003eUse this option with `sourceMap:false` if you are interested only in keeping the line numbering.\u003cbr\u003e**Default** `false` |\n| mapHires | boolean | Make a hi-res source-map, if `sourceMap:true` (the default).\u003cbr\u003e**Default** `true` |\n| prefixes | string \u0026vert; RegExp \u0026vert;\u003cbr\u003eArray\u0026lt;string\u0026vert;RegExp\u0026gt; | The start of a directive. That is the characters before the '#', usually the start of comments.\u003cbr\u003e**Default** `['//', '/*', '\u003c!--']` (with one optional space after them). |\n| sourcemap | boolean | Must include a sourcemap?\u003cbr\u003eShould be the same value as the property `sourcemap` of the Rollup output.\u003cbr\u003e**Default** `true` |\n| mapContent | boolean | Include the original source in the sourcemap, if `sourceMap:true` (the default).\u003cbr\u003e**Default** `true` |\n| values | object | Plain object defining the variables used by jscc during the preprocessing.\u003cbr\u003e**Default** `{}` |\n| extensions | string \u0026vert; Array\u0026lt;string\u0026gt; | Array of strings that specifies the file extensions to process.\u003cbr\u003e**Default** `['js', 'jsx', 'ts', 'tsx', 'mjs', 'tag']` |\n| include | string \u0026vert; Array\u0026lt;string\u0026gt; | [minimatch](https://github.com/isaacs/minimatch) or array of minimatch patterns for paths that must be included in the processing. |\n| exclude | string \u0026vert; Array\u0026lt;string\u0026gt; | [minimatch](https://github.com/isaacs/minimatch) or array of minimatch patterns for paths that should be ignored. |\n\n## Directives\n\nPlease see the [jscc wiki](https://github.com/aMarCruz/jscc/wiki) to know about directives used by jscc.\n\n## What's New\n\nPlease see the [CHANGELOG](CHANGELOG.md).\n\n## License\n\nThe [MIT License](LICENSE)\n\n[npm-badge]: https://img.shields.io/npm/v/rollup-plugin-jscc.svg\n[npm-url]: https://www.npmjs.com/package/rollup-plugin-jscc\n[build-badge]: https://img.shields.io/travis/aMarCruz/rollup-plugin-jscc.svg\n[build-url]: https://travis-ci.org/aMarCruz/rollup-plugin-jscc\n[wbuild-badge]: https://img.shields.io/appveyor/ci/aMarCruz/rollup-plugin-jscc/master.svg?style=flat-square\n[wbuild-url]: https://ci.appveyor.com/project/aMarCruz/rollup-plugin-jscc/branch/master\n[climate-badge]: https://api.codeclimate.com/v1/badges/896211f2169f2c1dcd62/maintainability\n[climate-url]: https://codeclimate.com/github/aMarCruz/rollup-plugin-jscc/maintainability\n[codecov-badge]: https://codecov.io/gh/aMarCruz/rollup-plugin-jscc/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/aMarCruz/rollup-plugin-jscc\n[license-badge]: https://img.shields.io/npm/l/express.svg\n[license-url]: https://github.com/aMarCruz/rollup-plugin-jscc/blob/master/LICENSE\n[kofi-url]: https://ko-fi.com/C0C7LF7I\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Frollup-plugin-jscc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FaMarCruz%2Frollup-plugin-jscc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FaMarCruz%2Frollup-plugin-jscc/lists"}