0beqz/screen-space-reflections

Cannot use import statement outside a module

Closed this issue · 9 comments

First off, incredible work here! We are using @react-postprocessing inside of a Jenkins build pipeline, and the following error just started showing up and breaking the build process. Looks like @react-postprocessing started including the SSRPass as part of their package.

/node_modules/screen-space-reflections/ScreenSpaceReflections.js:25
import { Pass, RenderPass, DepthPass, KernelSize, KawaseBlurPass } from 'postprocessing';

SyntaxError: Cannot use import statement outside a module
0beqz commented

Thanks, I appreciate it.
That's weird, I think that could be due to the package.json of the module now that I compared it with the package.json of other modules that also use the import statement (e.g. postprocessing.js).
So can you navigate to node_modules/screen-space-reflections/package.json in your project to open the package.json file of the module? From there change the main attribute to module.

The attribute should be here in the package.json: https://github.com/0beqz/screen-space-reflections/blob/main/dist/package.json#L5
Just change it to "module" like it is here for example: https://github.com/pmndrs/postprocessing/blob/main/package.json#L7

If that still doesn't work, try to add type: "module" to the package.json. Let me know if that fixes the issue.

ah yes, i think it should be "module". if you want i can make a PR for module and cjs support, for instance i could do it like this: https://github.com/pmndrs/tunnel-rat do you want simple annotational typescript support btw? i don't use ts either but i have it in most libs because that way IDE's autocomplete and show the docs on hover.

0beqz commented

Yeah sure, I'd appreciate if you could make a PR to add CJS support and TypeScript annotations.

Thank you both. Happy to test and confirm once the PR is merged!

this should work: #6

0beqz commented

It's merged. You can test now if the error is gone

Still doesn't work in next.js

could you publish it @0beqz ? im getting complaints for react-pp as it has ssr in dependencies. without "module" these systems treat it as a regular js file that can't have imports in them.

0beqz commented

It's published now, version 1.0.8