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

Remove yamlparser dependency #39242

Closed
wants to merge 1 commit into from
Closed

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Feb 4, 2020

Seems like we introduced yamlparser as a dependency in #30768. It doesn't seem to be used, though - @sgomes were we planning to use it for anything? If not, it could be removed safely.

Changes proposed in this Pull Request

  • Remove yamlparser dependency

Testing instructions

  • Checkout this branch.
  • Run npm ci and verify Calypso builds well.

@tyxla tyxla added Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Type] Janitorial labels Feb 4, 2020
@tyxla tyxla requested review from sgomes and a team February 4, 2020 10:08
@tyxla tyxla self-assigned this Feb 4, 2020
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@tyxla
Copy link
Member Author

tyxla commented Feb 4, 2020

Actually, it seems like this is necessary by useragent for the desktop environment. The interesting fact though is that it's a dev dependency there. Should we alter it to be a dev dependency here, too?

@sgomes
Copy link
Contributor

sgomes commented Feb 4, 2020

Hey @tyxla 👋

The issue is that useragent (one of our transitive dependencies) requires yamlparser in some situations (see line 15 in https://unpkg.com/browse/useragent@2.3.0/lib/update.js). Unfortunately, it specifies it as a devDependency, rather than a dependency in its package.json, even though it can be used at runtime.

As such, we needed to explicitly depend on this ourselves.

It's unclear to me why some builds need lib/update.js and some don't, however, so perhaps that's one way of fixing the issue?

@jsnajdr
Copy link
Member

jsnajdr commented Feb 4, 2020

I also tried to remove yamlparser when working on #38190, but as @sgomes said, it's a workaround for a bug in useragent/package.json, which specifies its dependencies incorrectly.

When one removes yamlparser, the desktop server build fails. Why doesn't the classic server fail, too? I think it's because the server build externalizes all require() calls that resolve to node_modules. Such require() calls are not resolved by webpack and the required libraries are not bundled. The require() calls are left in the bundled JS code and Node.js resolves them at runtime.

Because the yamlparser is required dynamically, inside a function, you'd need to call that function to trigger a runtime error. And apparently we never call that particular function.

When building the desktop server and bundling all node_modules into the output bundle, the require calls are resolved statically and the build fails.

@tyxla
Copy link
Member Author

tyxla commented Feb 4, 2020

Thanks for clarifying, guys.

At this point, I'd call this a false alarm then. It's a shame it's being depended on in such a convoluted and non-transparent way, though.

Closing.

@tyxla tyxla closed this Feb 4, 2020
@tyxla tyxla deleted the remove/yamlparser-dependency branch February 4, 2020 11:32
@tyxla tyxla removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Feb 4, 2020
@jsnajdr
Copy link
Member

jsnajdr commented Feb 4, 2020

It's a pity we can't add explanatory comments to package.json. 😢 This dependency would deserve one.

@sgomes
Copy link
Contributor

sgomes commented Feb 4, 2020

It's a pity we can't add explanatory comments to package.json. 😢 This dependency would deserve one.

We could technically add them, as new keys. Since yamlparser is right at the bottom, we could do something like:

{
  "dependencies": {
    "...": "...",
    "yamlparser": "0.0.2"
  },
  "__comment__": "See https://github.com/Automattic/wp-calypso/pull/39242 for why we need yamlparser"
}

Not pretty, though 😕

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

Successfully merging this pull request may close these issues.

4 participants