Skip to content
This repository was archived by the owner on Apr 19, 2026. It is now read-only.

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

Merged
developit merged 1 commit intoGoogleChromeLabs:masterfrom
arturovt:fix/issue-25
Jan 4, 2020
Merged

fix: replace type property with undefined except of replacing with empty string#49
developit merged 1 commit intoGoogleChromeLabs:masterfrom
arturovt:fix/issue-25

Conversation

@arturovt
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor

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

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

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