rollup-plugin-minify-html-literals icon indicating copy to clipboard operation
rollup-plugin-minify-html-literals copied to clipboard

TypeError: minifyHTML is not a function

Open Atulin opened this issue 3 years ago • 7 comments

import minifyHTML from 'rollup-plugin-minify-html-literals';

const bundle = await rollup.rollup({
	input: `${roots.js}/src/components/**/*.ts`,
	output: {
		file: out,
		format: "es",
		sourcemap: true
	},
	plugins: [
		multi(),
		resolve(),
		minifyHTML(),
		esbuild({
			tsconfig: "./tsconfig.json",
			minify: true,
		}),
	]
});

Atulin avatar May 15 '22 21:05 Atulin

I'm not able to reproduce this, I assume this is a rollup.config.js file passed to rollup -c?

Can you add more details such as the error stack trace and what version of rollup/node you're using?

asyncliz avatar May 18 '22 16:05 asyncliz

It's actually a part of my Gulp pipeline. Here, let me post the whole Gulp task:

"use strict";
import { pipeline } from "stream";
import gulp from "gulp";
import * as minifyHTML from 'rollup-plugin-minify-html-literals';
import * as rollup from "rollup";
import resolve from "@rollup/plugin-node-resolve";
import rollupTs from "@rollup/plugin-typescript";
import multi from "@rollup/plugin-multi-entry";
import esbuild from "rollup-plugin-esbuild";

// Component bundle
export const components = async () => pipeline(gulp.src(`${roots.js}/src/wcomps/**/*.ts`),
	async () => {
		const out = `${roots.js}/bundle/components.js`;
		const bundle = await rollup.rollup({
			input: `${roots.js}/src/wcomps/**/*.ts`,
			output: {
				file: out,
				format: "es",
				sourcemap: true
			},
			plugins: [
				multi(),
				resolve(),
				minifyHTML(),
				esbuild({
					tsconfig: "./Ogma3/wwwroot/js/tsconfig.json",
					minify: true,
				}),
			]
		});
		return bundle.write({
			file: out,
			format: "umd",
			name: "components",
			sourcemap: true
		});
	},
	errorHandler);

For reference, I finally got it working with this package: https://github.com/jleeson/rollup-plugin-html-literals

Atulin avatar May 18 '22 19:05 Atulin

I'm getting the same error as well.

PaulHMason avatar May 20 '22 08:05 PaulHMason

I was getting the same issue using Vite. This worked for me:

import pkgMinifyHTML from 'rollup-plugin-minify-html-literals';
const minifyHTML = pkgMinifyHTML.default

That said it seriously breaks my app so it is a non-starter for me. I assume it is an issue with: https://www.npmjs.com/package/minify-html-literals

clibu avatar Jun 02 '22 02:06 clibu

For me this works with rollup 2.79.1, but crashes with rollup 3.2.2. I use Node 14.19.0. Changelog at Rollup 3.0.0. (2022-10-11): Rollup now requires at least Node 14.18.0 to run (#4548 and #4596) https://github.com/rollup/rollup/blob/master/CHANGELOG.md

tug-guenter avatar Oct 17 '22 13:10 tug-guenter

This started happening for me when I changed the package to the type of module and changed the rollup.config extension to mjs.

To get around it use minifyHTML.default();

I suspect this is because this package is not of type module.

mjgchase avatar Mar 16 '23 20:03 mjgchase

Will this be investigated?

motiejunas avatar Apr 03 '23 12:04 motiejunas