{"id":13774379,"url":"https://github.com/swiing/rollup-plugin-import-attributes","last_synced_at":"2026-04-21T18:48:08.350Z","repository":{"id":37085645,"uuid":"468030531","full_name":"swiing/rollup-plugin-import-attributes","owner":"swiing","description":"A Rollup plugin which bundles TC39 import attributes.","archived":false,"fork":false,"pushed_at":"2024-12-22T12:51:16.000Z","size":394,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T18:46:30.660Z","etag":null,"topics":["assertions","attributes","css","import","json","plugin","rollup"],"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/swiing.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-09T17:36:46.000Z","updated_at":"2024-12-24T21:22:13.000Z","dependencies_parsed_at":"2022-06-24T15:31:09.818Z","dependency_job_id":"f74ba910-4970-4106-8fcb-8cc79a93a4ac","html_url":"https://github.com/swiing/rollup-plugin-import-attributes","commit_stats":null,"previous_names":["swiing/rollup-plugin-import-attributes","swiing/rollup-plugin-import-assertions"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiing%2Frollup-plugin-import-attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiing%2Frollup-plugin-import-attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiing%2Frollup-plugin-import-attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiing%2Frollup-plugin-import-attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiing","download_url":"https://codeload.github.com/swiing/rollup-plugin-import-attributes/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253528403,"owners_count":21922623,"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":["assertions","attributes","css","import","json","plugin","rollup"],"created_at":"2024-08-03T17:01:26.170Z","updated_at":"2026-04-21T18:48:08.281Z","avatar_url":"https://github.com/swiing.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Modules"],"readme":"[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n# rollup-plugin-import-attributes\n\n🍣 A Rollup plugin which bundles [import attributes](https://github.com/tc39/proposal-import-attributes).\n\nTwo types of attributes are supported: `json` and `css`.\n\nCurrently, dynamic imports are not supported (PR welcomed).\n\n## Install\n\nUsing npm:\n\n```console\nnpm install rollup-plugin-import-attributes --save-dev\n```\n\n## Usage\n\nCreate a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:\n\n```js\nimport importAttributes from 'rollup-plugin-import-attributes';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs'\n  },\n  plugins: [importAttributes()]\n};\n```\n\nThen call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).\n\nWith an accompanying file `src/index.js`, the local `package.json` file would now be importable as seen below:\n\n```js\n// src/index.js\nimport pkg from '../package.json' assert { type: 'json' };\nconsole.log(`running version ${pkg.version}`);\n```\n\nIt is also possible to import css stylesheets, typically when designing web components:\n\n```js\n// src/mycomponent.js\nimport style from './style.css' assert { type: 'css' };\n\nclass MyElement extends HTMLElement {\n  constructor() {\n    super();\n    const root = this.attachShadow({ mode: 'open' });\n    root.adoptedStyleSheets = [styles];\n    root.innerHTML = `\u003cdiv\u003eMy custom element\u003c/div\u003e`;\n  }\n}\n\ncustomElements.define('my-element', MyElement);\n```\n\n## Options\n\nFor the `json` type of aattribute, this plugin accepts the same options\nas those of [@rollup/plugin-json](https://github.com/rollup/plugins/tree/master/packages/json/).\nThis makes it straight-forward to move to import attributes, should one wish so.\n\nFor the `css` type of attribute, this plugin accepts the usual `include` and `exclude` options.\n\n### `compact` (type: 'json')\n\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nIf `true`, instructs the plugin to ignore `indent` and generates the smallest code.\n\n### `exclude`\n\nType: `String` | `Array[...String]`\u003cbr\u003e\nDefault: `null`\n\nA [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. By default no files are ignored.\n\n### `include`\n\nType: `String` | `Array[...String]`\u003cbr\u003e\nDefault: `null`\n\nA [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.\n\n### `indent` (type: 'json')\n\nType: `String`\u003cbr\u003e\nDefault: `'\\t'`\n\nSpecifies the indentation for the generated default export.\n\n### `namedExports` (type: 'json')\n\nType: `Boolean`\u003cbr\u003e\nDefault: `true`\n\nIf `true`, instructs the plugin to generate a named export for every property of the JSON object.\n\n### `preferConst` (type: 'json')\n\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nIf `true`, instructs the plugin to declare properties as variables, using either `var` or `const`. This pertains to tree-shaking.\n\n## Credits\n\nCredits to:\n\n- [@rollup/plugin-json](https://github.com/rollup/plugins/tree/master/packages/json/),\n  on top of which this plugin shamelessly builds.\n\n- [rollup-plugin-import-assert](https://github.com/calebdwilliams/rollup-plugin-import-assert) which was inspirational to start with.\n\n## License\n\n![license](https://img.shields.io/github/license/swiing/rollup-plugin-import-attributes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiing%2Frollup-plugin-import-attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiing%2Frollup-plugin-import-attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiing%2Frollup-plugin-import-attributes/lists"}