Elderjs / plugins

Elder.js plugins and community plugins.
https://elderguide.com/tech/elderjs/
MIT License
81 stars 20 forks source link

images plugin 1.8.0-beta.7 is missing built files #163

Open markjaquith opened 1 year ago

markjaquith commented 1 year ago

If you look at the images plugin fetched via npm, it's missing files in the build/workers directory.

❯ ls @elderjs/plugin-images/build
index.js  index.mjs

But if you look at the markdown plugin, its utils directory is there.

❯ ls @elderjs/plugin-markdown/build
index.cjs  index.d.ts index.js   utils

Of note: the images plugin is not "type": "module". If you convert it to that, you'll have to fix the use of __dirname to use ESM-friendly stuff. Not sure if just doing that is enough to fix the build issue, or if something else is going on.

nickreese commented 1 year ago

@markjaquith This is an issue with tsup's default configured bundling. Because it only bundles obvious imports the way the workers are imported the files weren't detected.

I shipped a potential fix in 1.8.0-beta.8 that should work with cjs assuming the bundling works. Will be testing it on our cjs projects.

markjaquith commented 1 year ago

@nickreese The files are there now, but now I'm getting this:

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/mark/Sites/markjaquith.com/node_modules/@elderjs/plugin-images/build/workers/resize.js from /Users/mark/Sites/markjaquith.com/node_modules/worker-nodes/lib/worker/child-loader.js not supported.
Instead change the require of resize.js in /Users/mark/Sites/markjaquith.com/node_modules/worker-nodes/lib/worker/child-loader.js to a dynamic import() which is available in all CommonJS modules.
    at setupModule (/Users/mark/Sites/markjaquith.com/node_modules/worker-nodes/lib/worker/child-loader.js:11:15)
    at MessagePort.<anonymous> (/Users/mark/Sites/markjaquith.com/node_modules/worker-nodes/lib/worker/child-loader.js:88:20) {
  code: 'ERR_REQUIRE_ESM'
}