Skip to content

Commit

Permalink
fix(html): prepare for Rollup 3 (#1294)
Browse files Browse the repository at this point in the history
BREAKING CHANGES: Requires Node 14
  • Loading branch information
lukastaegert committed Oct 9, 2022
1 parent f2b0004 commit e49fb5f
Show file tree
Hide file tree
Showing 6 changed files with 433 additions and 689 deletions.
2 changes: 1 addition & 1 deletion packages/html/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Please see [Supported Output Formats](#supported-output-formats) for information

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.

## Install

Expand Down
26 changes: 17 additions & 9 deletions packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
"import": "./dist/es/index.js",
"types": "./types/index.d.ts",
"default": "./dist/cjs/index.js"
},
"engines": {
"node": ">= 8.0.0"
"node": ">=14.0.0"
},
"scripts": {
"build": "rollup -c",
Expand All @@ -37,6 +38,7 @@
},
"files": [
"dist",
"!dist/**/*.map",
"types",
"README.md",
"LICENSE"
Expand All @@ -48,15 +50,21 @@
"template"
],
"peerDependencies": {
"rollup": "^1.20.0||^2.0.0"
"rollup": "^1.20.0||^2.0.0||^3.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
},
"devDependencies": {
"@rollup/plugin-typescript": "^6.1.0",
"rollup": "^2.67.3",
"rollup-plugin-postcss": "^3.1.8",
"typescript": "^4.1.2"
"@rollup/plugin-typescript": "^8.5.0",
"postcss": "^8.4.16",
"rollup": "^3.0.0-7",
"rollup-plugin-postcss": "^4.0.2",
"typescript": "^4.8.3"
},
"types": "types/index.d.ts",
"types": "./types/index.d.ts",
"ava": {
"workerThreads": false,
"files": [
Expand Down
9 changes: 2 additions & 7 deletions packages/html/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@ import { extname } from 'path';

import { Plugin, NormalizedOutputOptions, OutputBundle, EmittedAsset } from 'rollup';

import { RollupHtmlOptions, RollupHtmlTemplateOptions } from '../types';
import type { RollupHtmlOptions, RollupHtmlTemplateOptions } from '../types';

const getFiles = (bundle: OutputBundle): RollupHtmlTemplateOptions['files'] => {
const files = Object.values(bundle).filter(
(file) =>
file.type === 'chunk' ||
(typeof file.type === 'string' ? file.type === 'asset' : file.isAsset)
);
const result = {} as ReturnType<typeof getFiles>;
for (const file of files) {
for (const file of Object.values(bundle)) {
const { fileName } = file;
const extension = extname(fileName).substring(1);

Expand Down
6 changes: 4 additions & 2 deletions packages/html/test/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,11 @@ Generated by [AVA](https://avajs.dev).
[
{
chunkName: 'batman',
code: 'EMPTY_BUNDLE',
message: 'Generated an empty chunk: "batman"',
message: 'Generated an empty chunk: "batman".',
names: [
'batman',
],
toString: Function {},
},
{
Expand Down
Binary file modified packages/html/test/snapshots/test.js.snap
Binary file not shown.
Loading

0 comments on commit e49fb5f

Please sign in to comment.