parcel-bundler / awesome-parcel

🔗 A curated list of awesome Parcel resources, libraries, tools and boilerplates
1.39k stars 88 forks source link

Added parcel-plugin-codegen #80

Closed FlorianRappl closed 4 years ago

FlorianRappl commented 4 years ago

Thanks for taking care of this PR :beers:!

mischnic commented 4 years ago

An interesting plugin! Just to verify: have you tested that these assets are always reevaluated (because the foo.codegen file could return a different function although the file content didn't change). e.g. this case:


module.exports = function() {
  return `module.exports = ${Math.random()}`;
};
FlorianRappl commented 4 years ago

The example you mentioned would be a constant (e.g., if you reference this codegen module from two modules A and B, then both would see the same value).

The codegen'ed module gets only re-evaluated if one of the dependent files changes. As an example consider how I created a dynamic (lazy loaded) SPA blog using React with Parcel / codegen: https://www.youtube.com/watch?v=QQx8xawxFK0

Not sure if always reevaluating would be interesting (maybe as an option it would be).

Right now the PR validation is failing, but as far as I can see it has nothing to do with my addition.