You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah I understand that. I wasn't able to recreate using ES modules so I'm fairly certain that the createCommonjsModule code is the culprit here. I can see from looking at it that it's probably very hard to fix.
This case comes down to an ordering issue. joi.js depends on schema.js, but doesn't need it in the module body. schema.js does need joi.js in the module body. If the modules were ordered the opposite it might be ok.
Using @rollup/plugin-commonjs with postcss does not correctly resolve internal files within postcss, for example ./lib/container.js from ./lib/rule.js. The root cause seems to be circular dependencies, caused by mixing import and require statements before Babel transpilation: https://github.com/postcss/postcss/blob/master/lib/container.es6#L609
@shellscape Hopefully this isn't considered a "me too", but... I'm not sure exactly what to do here. I'm trying to use Snowpack+Rollup for the first time and ran into this with zod. The issue is likely the same or very similar to this issue.
Unless I'm missing something, there are still issues with circular dependencies in the rollup commonjs plugin which are known. The only workaround appears to be to change the package being rolled up to work around the circular dependencies (which involves quite a bit of work in 3rd party code in some instances).
Are there plans to revisit this? Would another issue with a different repro help? I highly doubt my single 👍 on a closed issue will make a difference, so I hope you don't mind me chiming in with a little more context here. Thanks!
Activity
shellscape commentedon Dec 31, 2019
There are a litany of circular reference issues in the main rollup project. The likelihood that there's a good solution for this is pretty slim.
matthewp commentedon Dec 31, 2019
Yeah I understand that. I wasn't able to recreate using ES modules so I'm fairly certain that the createCommonjsModule code is the culprit here. I can see from looking at it that it's probably very hard to fix.
matthewp commentedon Dec 31, 2019
This case comes down to an ordering issue.
joi.jsdepends onschema.js, but doesn't need it in the module body.schema.jsdoes needjoi.jsin the module body. If the modules were ordered the opposite it might be ok.[-]Commonjs unable to resolve circular reference[/-][+]Unable to resolve circular reference[/+]Haringat commentedon Jan 16, 2020
@matthewp I'm curious... Would it work if you first imported the schema.js and then imported the main joi entrypoint?
shellscape commentedon Jan 16, 2020
From #164:
How Do We Reproduce?
Using @rollup/plugin-commonjs with
postcssdoes not correctly resolve internal files withinpostcss, for example./lib/container.jsfrom./lib/rule.js. The root cause seems to be circular dependencies, caused by mixingimportandrequirestatements before Babel transpilation: https://github.com/postcss/postcss/blob/master/lib/container.es6#L609Here is a complete example: https://glitch.com/edit/#!/mapgrid-rollup-postcss-repro?path=rollup.config.js:1:0
And a repo: https://github.com/mapgrid/rollup-postcss-repro/
Build log
Runtime error
Where
superClassis the export from./lib/container.jsmatthewp commentedon Jan 16, 2020
@Haringat It might very well, but as I had to switch to webpack for this project I am not able to test and confirm that at this time.
shellscape commentedon May 2, 2020
Hey folks, this one has gone quite stale. We're going to close for housekeeping but we'd happily review any PRs that pop up to resolve this issue.
heathermiller commentedon May 25, 2020
shellscape commentedon May 25, 2020
Please don't reply with "me too" or "same" posts. Instead, use the reaction buttons on the original post.
aaronjensen commentedon Dec 1, 2020
@shellscape Hopefully this isn't considered a "me too", but... I'm not sure exactly what to do here. I'm trying to use Snowpack+Rollup for the first time and ran into this with zod. The issue is likely the same or very similar to this issue.
Unless I'm missing something, there are still issues with circular dependencies in the rollup commonjs plugin which are known. The only workaround appears to be to change the package being rolled up to work around the circular dependencies (which involves quite a bit of work in 3rd party code in some instances).
Are there plans to revisit this? Would another issue with a different repro help? I highly doubt my single 👍 on a closed issue will make a difference, so I hope you don't mind me chiming in with a little more context here. Thanks!
shellscape commentedon Dec 1, 2020
well, there is #658 (searching for the win)
aaronjensen commentedon Dec 1, 2020
That's great, thanks. And now there's a reference for folks who only searched issues and not PRs like myself.