Open njfamirm opened 10 months ago
Hey @njfamirm 👋
Currently Pagefind's npm interface only supports being used as an ESM module via import, rather than as a CJS package through require.
I haven't run it to confirm, but changing to an async import should work for you. Also, addDirectory
and writeFiles
aren't imported from the pagefind module itself, but are instead methods on the index
returned from createIndex
:
async function indexContent() {
const { createIndex, close } = await import('pagefind');
const { index } = await createIndex();
await index.addDirectory({path: 'dist'});
await index.writeFiles({outputPath: 'dist/pagefind'});
await close();
}
module.exports = {indexContent};
Thanks @bglw! I'm test it.
would you like to include cjs
in the output with the build tools? and publish to npm?
I don't know the process, but probably in the next few days I want to do this for our own packages.
If you want, I can do it for this project as well 🙌🏻
For now I'd like to wait and see how often this crops up. The wrapper package currently doesn't go through any build process, so I'm hesitant to add a build process there when the package can be async imported in a pinch.
Hi 🙌🏻
when i want to use this in the 11ty with cjs, with below config,
this is my current config:
have this error:
how can solve it?
thanks...