rollup-plugin-output-manifest
rollup-plugin-output-manifest copied to clipboard
TypeError: outputManifest is not a function
Greetings,
I've the following setup:
import {defineConfig} from 'rollup';
import typescript from '@rollup/plugin-typescript';
import scss from 'rollup-plugin-scss';
import outputManifest from 'rollup-plugin-output-manifest/src';
export default defineConfig({
plugins: [
typescript(),
scss(),
outputManifest({
fileName: 'manifest.json',
publicPath: '/dist/',
})
],
input: 'frontend/public.ts',
output: {
file: 'root/dist/public.js',
}
})
When trying to execute the following rollup command:
./node_modules/.bin/rollup -c rollup.config.ts --configPlugin typescript
I'm getting the following output error:
[!] TypeError: outputManifest is not a function
And I'm not sure how I can resolve it.
Could you please check it?
Thank you!
I was able to work around this by doing
import pluginManifest from 'rollup-plugin-output-manifest'
const { default: outputManifest } = pluginManifest
Really not sure how this doesn't just work, it seems this library is just using an older version of TS that may have an outdated way of building CJS modules.
I had the modify the above solution to get it working with Vite.
It seems that the actual plugin function is named "default" and is within the default import (which is think is what the above solution is getting at).
Once you get past the little mess of code around the import, then you can use the plugin as normal.
import { defineConfig, type Plugin } from "vite";
// ...
// The type declarations don't match up the the very odd actual structure.
import outputManifestRawImport, {
type OutputManifestParam,
} from "rollup-plugin-output-manifest";
type OutputManifestPlugin = (param?: OutputManifestParam) => Plugin;
const outputManifest = (outputManifestRawImport as any)
.default as OutputManifestPlugin;
// ...
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
// ...
outputManifest({ /* ... */ }),
],
});
Official rollup plugins have simply support for esm and cjs like here: https://github.com/rollup/plugins/blob/33174f956304ab4aad4bbaba656f627c31679dc5/packages/json/package.json#L16-L22