{"id":31628033,"url":"https://github.com/jirutka/ts-transformer-inline-file","last_synced_at":"2025-10-06T20:17:05.463Z","repository":{"id":39782389,"uuid":"213218688","full_name":"jirutka/ts-transformer-inline-file","owner":"jirutka","description":"A TypeScript custom transformer for inlining files","archived":false,"fork":false,"pushed_at":"2023-01-07T10:25:56.000Z","size":162,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-14T13:57:47.373Z","etag":null,"topics":["inline","typescript","typescript-transformer"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jirutka.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"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":"2019-10-06T18:09:22.000Z","updated_at":"2023-09-06T10:40:13.000Z","dependencies_parsed_at":"2023-02-06T22:02:19.565Z","dependency_job_id":null,"html_url":"https://github.com/jirutka/ts-transformer-inline-file","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jirutka/ts-transformer-inline-file","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fts-transformer-inline-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fts-transformer-inline-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fts-transformer-inline-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fts-transformer-inline-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jirutka","download_url":"https://codeload.github.com/jirutka/ts-transformer-inline-file/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jirutka%2Fts-transformer-inline-file/sbom","scorecard":{"id":521633,"data":{"date":"2025-08-11","repo":{"name":"github.com/jirutka/ts-transformer-inline-file","commit":"eec4eb0000119376e728acc81690fa485a7287c5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/jirutka/ts-transformer-inline-file/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/jirutka/ts-transformer-inline-file/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/jirutka/ts-transformer-inline-file/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/jirutka/ts-transformer-inline-file/ci.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T03:09:51.779Z","repository_id":39782389,"created_at":"2025-08-20T03:09:51.779Z","updated_at":"2025-08-20T03:09:51.779Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278262443,"owners_count":25957938,"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","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["inline","typescript","typescript-transformer"],"created_at":"2025-10-06T20:17:03.879Z","updated_at":"2025-10-06T20:17:05.456Z","avatar_url":"https://github.com/jirutka.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"= TypeScript transformer for inlining files\n:npm-name: ts-transformer-inline-file\n:gh-name: jirutka/{npm-name}\n:gh-branch: master\n:vs-marketplace-uri: https://marketplace.visualstudio.com/items?itemName=\n\nifdef::env-github[]\nimage:https://github.com/{gh-name}/workflows/CI/badge.svg[Build Status, link=https://github.com/{gh-name}/actions?query=workflow%3A%22CI%22]\nimage:https://img.shields.io/npm/v/{npm-name}.svg[npm Version, link=\"https://www.npmjs.org/package/{npm-name}\"]\nendif::env-github[]\n\nThis is a TypeScript AST transformer footnote:[If you’ve never heard about TypeScript transformers, I can recommend https://blog.logrocket.com/using-typescript-transforms-to-enrich-runtime-code-3fd2863221ed/[this blog post] to dive into the topic.] that allows you to include content of a file into the transpiled code, i.e. _inline it_ in build-time.\n\nYou can think about it as a C preprocessor’s directive `#include` but more powerful… way more powerful.\nIf the referenced file is a JSON file, it doesn’t include it as a string but converts the JSON to an object literal.\nThus it can be further optimized by a minifier.\nMoreover, if you use an object destructing assignment, this transformer will optimize it itself -- include only the assigned properties!\n\n\n== Usage\n\nAdd {npm-name} package to your project as a **dev**elopment dependency and \u003c\u003cHow to Configure the Transformer, configure the transformer\u003e\u003e.\n\n\n=== Inline Any Textual File\n\n[source, js, subs=\"+attributes\"]\n----\nimport { $INLINE_FILE } from '{npm-name}'\n\nconst words = $INLINE_FILE('../data/words.txt').trim().split(' ')\n----\n\nThis will be transformed into:\n\n[source, js]\nconst words = \"lorem ipsum dolor\\n\".trim().split(' ');\n\n…where `\"lorem ipsum dolor\\n\"` is full content of the file `../data/words.txt`.\n\n\n=== Inline JSON Data\n\n[source, js, subs=\"+attributes\"]\n----\nimport { $INLINE_JSON } from '{npm-name}'\n\nconst pkg = $INLINE_JSON('../package.json')\n----\n\nThis will be transformed into:\n\n[source, js]\nconst pkg = { \"name\": \"my-package\", \"version\": \"0.1.0\", \"license\": \"MIT\", ... }\n\nHowever, if you need only few properties from the referenced JSON file, use object destructuring assignment:\n\n[source, js]\nconst { name, version } = $INLINE_JSON('../package.json')\n\n…and the transformer will include only the assigned properties:\n\n[source, js]\nconst { name, version } = { \"name\": \"my-package\", \"version\": \"0.1.0\" }\n\nNOTE: This works only for the top level; filtering of nested properties is currently not supported.\n\n\n== How to Configure the Transformer\n\nUnfortunately, TypeScript itself does not currently provide any easy way to use custom transformers (see https://github.com/Microsoft/TypeScript/issues/14419[Microsoft/TypeScript#14419]).\nFortunately, there are few solutions.\n\n\n=== TTypescript\n\nIf you don’t use any bundler such as Rollup or webpack, https://github.com/cevek/ttypescript[TTypescript] is the way to go.\nIt provides wrappers `ttsc` and `ttserver` for the `tsc` and `tsserver` commands that add support for custom transformers.\nAll you have to do is to use these wrappers instead of the original commands and define the transformer in your `tsconfig.json`:\n\n.tsconfig.json:\n[source, jsonc, subs=\"+attributes\"]\n----\n{\n  \"compilerOptions\": {\n    // ...\n    \"plugins\": [\n      { \"transform\": \"{npm-name}/transformer\" }\n    ]\n  },\n  // ...\n}\n----\n\n\n=== Rollup (with rollup-plugin-typescript2)\n\n.rollup.config.js:\n[source, js, subs=\"+attributes\"]\n----\nimport typescript from 'rollup-plugin-typescript2'\nimport inlineFileTransformer from '{npm-name}/transformer'\n\nexport default {\n  // ...\n  plugins: [\n    typescript({\n      transformers: [\n        (service) =\u003e ({\n          before: [ inlineFileTransformer(service.getProgram()) ],\n          after: [],\n        }),\n      ],\n    }),\n  ],\n}\n----\n\n\n=== Webpack (with ts-loader or awesome-typescript-loader)\n\n.webpack.config.js:\n[source, js, subs=\"+attributes\"]\n----\nconst inlineFileTransformer = require('{npm-name}/transformer').default\n\nmodule.exports = {\n  // ...\n  module: {\n    rules: [\n      {\n        test: /\\.ts$/,\n        loader: 'ts-loader', // or 'awesome-typescript-loader',\n        options: {\n          getCustomTransformers: (program) =\u003e ({\n            before: [\n              inlineFileTransformer(program),\n            ],\n          }),\n        },\n      },\n    ],\n  },\n}\n----\n\n\nifndef::npm-readme[]\n\n== Development\n\n=== System Requirements\n\n* https://nodejs.org[NodeJS] 14+\n* https://pandoc.org[Pandoc] and https://asciidoctor.org[Asciidoctor] (used only for converting README.adoc to Markdown for npmjs)\n\n\n=== Used Tools\n\n* https://www.typescriptlang.org[TypeScript] the language\n* https://yarnpkg.com[yarn] for dependencies management and building\n* https://eslint.org[ESLint] for linting JS/TypeScript code\n* https://github.com/substack/tape[tape] for testing\n\n\n=== How to Start\n\n. Clone this repository:\n[source, subs=\"+attributes\"]\ngit clone https://github.com/{gh-name}.git\ncd {npm-name}\n\n. Install Yarn (if you don’t have it already):\n[source]\nnpm install -g yarn\n\n. Install all JS dependencies:\n[source]\nyarn install\n\n. Build the project:\n[source]\nyarn build\n\n. Run tests:\n[source]\nyarn test\n\n. Run linter:\n[source]\nyarn lint\n\n\n=== Visual Studio Code\n\nIf you use Visual Studio Code, you may find the following extensions useful:\n\n* link:{vs-marketplace-uri}EditorConfig.EditorConfig[EditorConfig for VS Code]\n* link:{vs-marketplace-uri}dbaeumer.vscode-eslint[ESLint]\n* link:{vs-marketplace-uri}gamunu.vscode-yarn[yarn]\n\nendif::[]\n\n\n== License\n\nThis project is licensed under http://opensource.org/licenses/MIT/[MIT License].\nFor the full text of the license, see the link:LICENSE[LICENSE] file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fts-transformer-inline-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjirutka%2Fts-transformer-inline-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjirutka%2Fts-transformer-inline-file/lists"}