Finished migrating from to . The generated code got much more readable (yes, I don't minimize it on purpose). It's also way easier to debug without IIFE, all global variables stay global. github.com/palant/pfp/commit/1

I like the way is configured, in my case the configuration is very compact and I don't have to disable undesirable default behavior. The one plugin I had also got considerably simpler, no tricks necessary to make Rollup render a file in memory.

In the process I migrated the remaining parts of the codebase to ES6 modules, something that was non-trivial due to unit tests running on (meaning: no native module support). The other (unexpected) complication were circular dependencies.

With CommonJS, circular dependencies are obviously problematic - you might refer to a module that didn't finish setting up its exports yet. You avoid this issue by dropping the immediate require() call, delayed loading works fine then.

This issue doesn't exist with ES6 modules, the namespaces of all modules being merged at compile time. But you get another issue: the order in which the modules initialize themselves is essentially undefined, you might be accessing functionality that hasn't been initialized yet.

Follow

The only reliable way of avoiding this issue is really getting rid of all circular dependencies. So I restructured the code a bit, and in a few cases I had a module provide a callback to another in order to avoid an explicit dependency there. Not necessarily fancy but it works.

Sign in to participate in the conversation
Infosec Exchange

A Mastodon instance for info/cyber security-minded people.