New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

More events! #1660

Open
sw-yx opened this Issue Jul 3, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@sw-yx
Copy link

sw-yx commented Jul 3, 2018

馃檵 feature request

Hello, I was working on a static site generator using parcel. I think the events system could be expanded to accommodate other tooling that hooks into parcel to understand a project's structure and does stuff around it (so that I can take advantage of parcel's code splitting for example).

馃 Expected Behavior

add an event for every time a new asset is bundled.

optionally, also add an event based on filetypes (so its like a subset of the above event, but much easier for a very common use case)

馃槸 Current Behavior

currently buildEnd and bundled only emit when the bundling is complete.

馃拋 Possible Solution

not sure, I haven't read the source code yet, but plan to.

馃敠 Context

How has this issue affected you? What are you trying to accomplish?

I am trying to make a static site generator. it would be great to hook into parcel so I can do my data injection logic alongside parcel, instead of only after the bundling is complete. its a much simpler way of doing it than crawling the built tree myself, and probably wouldn't be too much work on parcel's part.

馃捇 Examples

const bundler = new Bundler(...);
bundler.on('assetBundled', (asset) => {
// for each asset, execute this callback
});
bundler.on({ name: 'assetBundled', type: 'js' }, (asset) => {
// for each javascript asset, execute this callback
});
@yanglinz

This comment has been minimized.

Copy link

yanglinz commented Jul 6, 2018

I have a different use-case that would benefit from more event hooks as well.

I think Parcel would be a fantastic way to enable zero-config, modern JS bundling for other non-javascript web frameworks like Django. But I'd need a manifest of output files as they're generated, and not sure if the current event system would support that.

I'm not too familiar with Parcel's codebase yet, but let me know if there's a good place to start for this.

@KeineLimonade

This comment has been minimized.

Copy link
Contributor

KeineLimonade commented Jul 6, 2018

@yanglinz There is a a plugin that outputs a manifest. It is called something like parcel-plugin-manifest.

@sw-yx

This comment has been minimized.

Copy link

sw-yx commented Jul 6, 2018

I admit I haven't tried that specific plugin yet but I think the keyword here is "as-they're-generated", which seems doable?

@DeMoorJasper

This comment has been minimized.

Copy link
Member

DeMoorJasper commented Jul 11, 2018

More events is probably a good idea, but we shouldn't be going overkill with them as they might have a significant impact on performance if we overdo the amount of events

@sw-yx

This comment has been minimized.

Copy link

sw-yx commented Jul 11, 2018

ok - ONE event? :p 'assetBundled' event. should have no impact on perf if user doesn't implement it, and if the user does implement then they should accept the perf impact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment