Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to apply arbitrary plugins when compiling ServiceWorker script #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akihikodaki
Copy link

@akihikodaki akihikodaki commented Mar 20, 2018

I'd like to use this feature to embed some environment variables in my custom entry module with EnvironmentPlugin. I have optional CDN_HOST environment variable to determine an object storage in use. The entry module should have the variable, and be able to cache files served from the host.

There could be other use cases, considering the wide use of process.env.NODE_ENV. It is nice to have.

Question: I have not implemented a test case, but should I? Should I place it at tests/legacy or tests? (I'm not sure what legacy means.)

@NekR
Copy link
Owner

NekR commented Apr 14, 2018

Question: I have not implemented a test case, but should I? Should I place it at tests/legacy or tests? (I'm not sure what legacy means.)

Yeah, please, write tests. legacy it's just name, there were supposed to be new tests, but they were never made. Of course, if all tests are in tests/legacy, then you should put yours there as well.

@@ -30,6 +30,11 @@ export default class OfflinePlugin {
AppCache: false
});

if (options.ServiceWorker && options.ServiceWorker.plugins) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done in ServiceWorker.js file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be because it refers to options, not this.options.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds wrong. ServiceWorker options shouldn't be touched in index.js, they all are handled in ServiceWorker.js file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to clarify a bit more. It uses deepExtend to set up this.options, and addTool passes it to ServiceWorker.js. However, deepExtend breaks this.options.ServiceWorker.plugins and ServiceWorker.js can do nothing with it when received. Therefore it has to be fixed beforehand.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see what you mean now. It should be handled in some other way though. I'll merge this and do the change to this part myself.

(tests seem to fail now because master has been updated)

@NekR
Copy link
Owner

NekR commented Apr 26, 2018

I'll be happy to merge this once everything is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants