Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"rollup-plugin"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0||^5.0.0"
},
"peerDependenciesMeta": {
"rollup": {
Expand All @@ -64,7 +64,7 @@
},
"devDependencies": {
"@rollup/plugin-buble": "^1.0.0",
"rollup": "^4.0.0-24"
"rollup": "catalog:rollup-next"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Build tool drops Node 20

The new rollup-next dependency selects Rollup 5.0.0-2, which requires Node >=22.22.0. Both CI workflows still build and test this package on Node 20, and pretest runs the build too. Required CI jobs now use a build tool that does not support their Node version.

Keep the Node 20 build on Rollup 4 and run the Rollup 5 test on a supported Node version, or update the affected CI jobs.

},
"types": "./types/index.d.ts"
}
11 changes: 6 additions & 5 deletions packages/image/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@ export default function image(opts = {}) {
return {
name: 'image',

load(id) {
if (!filter(id)) {
load(id, loadOptions) {
const rawId = (loadOptions && loadOptions.rawId) || id;
if (!filter(rawId)) {
return null;
}

const mime = mimeTypes[extname(id)];
const mime = mimeTypes[extname(rawId)];
if (!mime) {
// not an image
return null;
}

this.addWatchFile(id);
this.addWatchFile(rawId);
const isSvg = mime === mimeTypes['.svg'];
const format = isSvg ? 'utf-8' : 'base64';
const source = readFileSync(id, format).replace(/[\r\n]+/gm, '');
const source = readFileSync(rawId, format).replace(/[\r\n]+/gm, '');
const dataUri = getDataUri({ format, isSvg, mime, source });
const code = options.dom ? domTemplate({ dataUri }) : constTemplate({ dataUri });

Expand Down
6 changes: 6 additions & 0 deletions packages/image/test/fixtures/svg-with-type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable */
import logo from './rollup.svg' with { type: 'image' };

const state = 'valid';

console.log(state, logo);
9 changes: 9 additions & 0 deletions packages/image/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@ test('imports an svg for dom, encodes for url', async () => {

expect(await getCode(bundle)).toMatchSnapshot();
});

test('loads images imported with import attributes', async () => {
const bundle = await rollup.rollup({
input: 'fixtures/svg-with-type.js',
plugins: [image({ include: '**/*.svg', exclude: /attributes/ })]
});

expect(await getCode(bundle)).toContain('data:image/svg+xml,');
});
Loading
Loading