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

fix: replace type property with undefined except of replacing with empty string #49

Merged
merged 1 commit into from
Jan 4, 2020

Conversation

arturovt
Copy link
Contributor

@arturovt arturovt commented Dec 23, 2019

Closes #25, #39

I'm facing the same issue in the Angular application as we're using Prettier in our project that automatically adds those commas.

This is a tiny change that doesn't introduce any breaking changes. I was trying to find some documentation for Webpack's parser helpers but wasn't able to.

@developit ping.


Previously, tests were failing if I added comma at the end:

Снимок экрана 2019-12-25 в 00 10 22

Copy link
Collaborator

@developit developit left a comment

Choose a reason for hiding this comment

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

I just realized this breaks the following code:

const name = 'my-worker';

new Worker('./worker.js', {
  type: "module",
  name: name
});

@developit
Copy link
Collaborator

@arturovt Another option might be to replace type:"module" with type:null. (toConstantDependency('type:null')).

@arturovt arturovt changed the title fix: replace the whole options object except of only type property fix: replace type property with undefined except of replacing with empty string Dec 29, 2019
@arturovt
Copy link
Contributor Author

arturovt commented Dec 29, 2019

@developit

type:null is invalid as browser throws:

The provided value 'null' is not a valid enum value of type WorkerType.

Browser doesn't throw if type value is undefined.

P.S. also checked it in Chrome/Mozilla/Safari and it works perfectly.

@arturovt arturovt requested a review from developit December 30, 2019 19:55
…h empty string

Options object can contain comma at the end e.g. `{ type: module, }`.
Previously, `type`, property was replaced with an empty string
that left this comma.
Currently the `type` property value is replaced with `undefined`.

Closes #25, #39
@developit
Copy link
Collaborator

Brilliant @arturovt! Thank you so much for checking in other browsers.

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.

Trailing Comma in the LoaderOption causes SyntaxError on removing type:module
2 participants