{"id":16791928,"url":"https://github.com/metonym/spre","last_synced_at":"2025-07-01T05:38:35.761Z","repository":{"id":57367967,"uuid":"393538055","full_name":"metonym/spre","owner":"metonym","description":"Svelte preprocessing utilities","archived":false,"fork":false,"pushed_at":"2021-08-07T00:47:33.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T05:33:31.354Z","etag":null,"topics":["preprocess","svelte"],"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/metonym.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":"2021-08-07T00:29:56.000Z","updated_at":"2021-10-16T18:21:10.000Z","dependencies_parsed_at":"2022-08-23T20:11:03.527Z","dependency_job_id":null,"html_url":"https://github.com/metonym/spre","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fspre","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fspre/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fspre/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/metonym%2Fspre/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/metonym","download_url":"https://codeload.github.com/metonym/spre/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960666,"owners_count":20375105,"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":["preprocess","svelte"],"created_at":"2024-10-13T08:43:31.806Z","updated_at":"2025-03-17T02:14:02.860Z","avatar_url":"https://github.com/metonym.png","language":"TypeScript","readme":"# spre\n\n\u003e Svelte preprocessing utilities\n\n## Installation\n\n**Yarn**\n\n```sh\nyarn add -D spre\n```\n\n**NPM**\n\n```sh\nnpm i -D spre\n```\n\n## Usage\n\n### onImportDeclaration\n\nUse `onImportDeclaration` to re-write imports in the script block.\n\n```diff\n- import { Ad as Ad2 } from \"svelte-lib\";\n- import { Bridge } from \"svelte-lib\";\n+ import Ad2 from \"svelte-lib/lib/Ad.svelte\";\n+ import Bridge from \"svelte-lib/lib/Bridge.svelte\";\n```\n\n```js\n// svelte.config.js\nimport spre from \"spre\";\n\nexport default {\n  preprocess: [\n    spre({\n      onImportDeclaration({ sourceName, importName, localName }) {\n        return `import ${localName} from \"${sourceName}/lib/${importName}.svelte\";`;\n      },\n    }),\n  ],\n};\n```\n\nExample that only re-writes non-default and not namespaced imports from a specific library:\n\n```js\nspre({\n  onImportDeclaration({ sourceName, importName, localName }) {\n    if (sourceName !== \"svelte-lib\") return;\n    if (isDefaultImport || !importName) return;\n    return `import ${localName} from \"${sourceName}/lib/${importName}.svelte\";`;\n  },\n}),\n```\n\n## License\n\n[MIT](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fspre","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmetonym%2Fspre","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmetonym%2Fspre/lists"}