{"id":15388082,"url":"https://github.com/calebdwilliams/rollup-plugin-import-assert","last_synced_at":"2025-04-15T17:33:00.812Z","repository":{"id":44951728,"uuid":"382974318","full_name":"calebdwilliams/rollup-plugin-import-assert","owner":"calebdwilliams","description":"Rollup plugin for working with ES module import assertions","archived":false,"fork":false,"pushed_at":"2023-05-04T00:58:01.000Z","size":826,"stargazers_count":9,"open_issues_count":2,"forks_count":9,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T22:29:23.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/calebdwilliams.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-07-05T00:27:40.000Z","updated_at":"2025-02-16T12:59:42.000Z","dependencies_parsed_at":"2023-09-26T09:07:49.062Z","dependency_job_id":null,"html_url":"https://github.com/calebdwilliams/rollup-plugin-import-assert","commit_stats":{"total_commits":24,"total_committers":5,"mean_commits":4.8,"dds":"0.29166666666666663","last_synced_commit":"bb56a340e8486fe562b355eb9fc78c7048fa5832"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebdwilliams%2Frollup-plugin-import-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebdwilliams%2Frollup-plugin-import-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebdwilliams%2Frollup-plugin-import-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calebdwilliams%2Frollup-plugin-import-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calebdwilliams","download_url":"https://codeload.github.com/calebdwilliams/rollup-plugin-import-assert/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249118953,"owners_count":21215647,"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":[],"created_at":"2024-10-01T14:55:26.102Z","updated_at":"2025-04-15T17:33:00.766Z","avatar_url":"https://github.com/calebdwilliams.png","language":"TypeScript","readme":"# rollup-plugin-import-assert\n\n🍣 A Rollup plugin which enables [import assertions](https://github.com/tc39/proposal-import-assertions) for top-level CSS and JSON modules. \n\n## Installation\n\nThis package is available on the npm registry under the name `rollup-plugin-import-assert` and can be installed with npm, yarn or however else you consume dependencies.\n\n### Example commands\n\nnpm: \n\n```zsh\nnpm i -D rollup-plugin-import-assert\n```\n\nyarn:\n\n```zsh\nyarn add -D rollup-plugin-import-assert\n```\n\n## Usage\n\nOnce the plugin is installed, you will also need to make sure you have the `acorn-import-assertions` package installed. You can then add both items to your Rollup configuration as below:\n\n```javascript\nimport { importAssertionsPlugin } from 'rollup-plugin-import-assert';\nimport { importAssertions } from 'acorn-import-assertions';\n\nexport default {\n  input: 'path/to/file.js'\n  output: {\n    format: 'esm',\n    dir: 'lib' // only necessary to enable dynamic imports\n  },\n  acornInjectPlugins: [ importAssertions ],\n  plugins: [ importAssertionsPlugin() ]\n}\n```\n\nThese two plugins will enable the import assertion syntax and behavior in your Rollup build. In your input file, you can import files using type assertions as follows:\n\n```javascript\nimport styles from './styles.css' assert { type: 'css' };\n\nclass MyCustomElement extends HTMLElement {\n  connectedCallback() {\n    const root = this.attachShadow({ mode: 'open' });\n    root.innerHTML = `\u003ch1\u003eHello world\u003c/h1\u003e`;\n    root.adoptedStyleSheets = [ styles ];\n  }\n}\n\ncustomElements.define('my-custom-element', MyCustomElement);\n```\n\nAssuming valid CSS in `styles.css`, the contents of the the CSS will be transformed to use CSS module scripts for use with `DocumentOrShadowRoot.prototype.adoptedStyleSheets`. Currently this API only exists in Chrome, but a [polyfill exists](https://www.npmjs.com/package/construct-style-sheets-polyfill) to port the behavior back to IE11.\n\n## Limitations\n\nThis plugin will ignore dynamic imports with dynamic values, e.g.: \n\n```js\nimport(`./foo/${bar}.json`, { assert: { type: 'json' } }); // will be ignored\n\nconst foo = './foo.json';\nimport(foo, { assert: { type: 'json' } }); // will be ignored\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalebdwilliams%2Frollup-plugin-import-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalebdwilliams%2Frollup-plugin-import-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalebdwilliams%2Frollup-plugin-import-assert/lists"}