Closed Kretiss closed 8 months ago
Got it to work with a workaround:
(PluginCritical as any).default({
criticalUrl: '',
criticalBase: './',
criticalPages: [{ uri: '', template: 'index' }],
criticalConfig: {},
}),
The any
is needed or else typescript will throw an error.
Got it to work with a workaround:
(PluginCritical as any).default({ criticalUrl: '', criticalBase: './', criticalPages: [{ uri: '', template: 'index' }], criticalConfig: {}, }),
The
any
is needed or else typescript will throw an error.
Thanks! Works!
hmmmm. I'm going to see if there's a way I can solve this at the plugin level
Okay so I was already properly generating a CJS and ESM variants of the library, but I needed to add Conditional Exports as a hint to help with module resolution:
https://nodejs.org/dist/latest-v18.x/docs/api/packages.html#conditional-exports
So what was happening is it was doing an import of the CJS version of the library, which worked likely because of the esModuleInterop
in your project's tsconfig.json
until the project was changed to "type": "module"
Adding this to the project's package.json
fixes it:
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
I'll roll out an update shortly.
Released as 1.0.13 -> https://github.com/nystudio107/rollup-plugin-critical/releases/tag/1.0.13
Describe the bug
Cannot build Vite project when using this plugin in plugins section in vite.config.ts. It says
TypeError: PluginCritical is not a function
. What am I doing wrong? I tried rollup.config.js, but it looks like Vite is ignoring that file.Steps to reproduce
import PluginCritical from 'rollup-plugin-critical'
Screenshots
Versions