kaicataldo / eleventy-plugin-react

A plugin that allows you to use React as a templating language for Eleventy
MIT License
38 stars 4 forks source link

API incompatibility with Eleventy 1.0 #33

Open mraerino opened 2 years ago

mraerino commented 2 years ago

When trying this Plugin with Eleventy 1.0 I get this error:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] > Having trouble writing template: _site/posts/hello/index.html

`TemplateWriterWriteError` was thrown
[11ty] > The "path" argument must be of type string. Received undefined

`TypeError` was thrown:
[11ty]     TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
        at new NodeError (node:internal/errors:370:5)
        at validateString (node:internal/validators:119:11)
        at Object.resolve (node:path:1098:7)
        at Object.<anonymous> (/Users/christine/code/kalkspace-relaunch/node_modules/eleventy-plugin-react/lib/plugin.js:122:28)
        at Template.runTransforms (/Users/christine/code/kalkspace-relaunch/node_modules/@11ty/eleventy/src/Template.js:553:38)
        at async Template.renderPageEntry (/Users/christine/code/kalkspace-relaunch/node_modules/@11ty/eleventy/src/Template.js:848:15)
        at async /Users/christine/code/kalkspace-relaunch/node_modules/@11ty/eleventy/src/Template.js:872:21
        at async Promise.all (index 0)
        at async Promise.all (index 2)
        at async Eleventy.executeBuild (/Users/christine/code/kalkspace-relaunch/node_modules/@11ty/eleventy/src/Eleventy.js:986:13)

this is likely because, the function context for addTransform callbacks no longer passes outputDir: https://github.com/11ty/eleventy/blob/08fe54e03da025cda24c4b25b5b8a8d0007b4689/src/Template.js#L552-L556 consider using path.dirname(outputPath) instead.

kaicataldo commented 2 years ago

Yeah, this hasn't been updated since v1.0 was released. Haven't had time since it was released, but will hopefully get to it soon. In the meantime, PRs are definitely welcome!