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

[core] Use common copy-files script #14406

Merged
merged 32 commits into from
Feb 5, 2019

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Feb 4, 2019

screenshot from 2019-02-04 09-59-34
🙌

copy-files is currently duplicated for every package that uses this logic with >99% overlap. This PR merges every single script into a common one. It helps refactoring build behavior (cumbersome for #13391 but will be easy with this change for e.g. #14392 if accepted) and brings some features to older packages such as:

  • adds typings field to every published package (core, docs, lab, system, utils)
  • applies [core] Improve tree-shakeability #13391 to @material-ui/docs
  • publishes types for @material-ui/icons/utils/createSVGIcon (includes /es build)
  • adds license header to icons and utils esm index barrel
  • publishes CHANGELOG.md to every package

Every single one of these points was done for one @material-ui/core

Fixes:

@eps1lon eps1lon added the core label Feb 4, 2019
@eps1lon eps1lon added this to the v4 milestone Feb 4, 2019
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

This pull request made me laugh. It's ridiculous from my part. I should have done this effort a long time ago instead of duplicating the script. Great move!

@@ -1,13 +1,16 @@
/* eslint-disable no-console */
const path = require('path');
Copy link
Member

Choose a reason for hiding this comment

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

We were using babel-node so we could write the source with es modules. I'm curious why you want to change this point.

Copy link
Member Author

Choose a reason for hiding this comment

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

babel-node:

  • imposes a runtime overhead
  • makes debugging harder if sourcemaps are not setup properly

it enables in our case:

  • es modules which don't provide any value in the node runtime

Copy link
Member

@oliviertassinari oliviertassinari Feb 4, 2019

Choose a reason for hiding this comment

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

My motivation was more: let's write the same code everywhere even if it's not the best tool for the job. The difference is negligeable. Simplicity first.

I didn't know about the source map issue.

Copy link
Member Author

@eps1lon eps1lon Feb 4, 2019

Choose a reason for hiding this comment

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

Let's defer this to a different PR then. I'll change to babel-node tomorrow.

I would like to get rid of it completely. Since node 8 already has async/await it doesn't add any value at the moment.

Copy link
Member

Choose a reason for hiding this comment

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

In some way, we might always need Babel. The JavaScript language is moving. Won't we need it too if we start using TypeScript?

Copy link
Member Author

Choose a reason for hiding this comment

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

Browser and node are two different targets. We use our node scripts only internally so requiring something like node 10 or 12 is not that big of a deal. Doing so removes the babel requirement apart from the latest es features and there is no big value gained by using those features.

Typescript for our node scripts is somewhat overkill at the moment. I think you're mixing various concepts here: babel-node has nothing to with our components (or Ssr). It's currently only used to use es modules in our node scripts that provide no benefit in the node runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried to revert but babel-node has some issues with transpiling code that is outside the cwd which is common in a monorepo: babel/babel#7566

This is fixable with the ignore flag but then we have to maintain those contents for every require and TL;DR: The amount of maintenance and time this adds to enable es modules in the node runtime (which don't add anything) is not worth it. At least it hasn't been shown to me.

We can revisit this once we need to transpile this dev script at runtime.

Copy link
Member

Choose a reason for hiding this comment

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

I have revisited a bit the implementation. Let me know what you think.

@oliviertassinari oliviertassinari force-pushed the core/single-copy-files branch 3 times, most recently from 1896f8a to ff4ba6d Compare February 5, 2019 08:03
@oliviertassinari
Copy link
Member

We had an issue with yarn lerna run build:copy-files.

@eps1lon
Copy link
Member Author

eps1lon commented Feb 5, 2019

Do with the PR as you please. I can't work on this if you refuse to provide a rationale.

@oliviertassinari oliviertassinari merged commit cce90f1 into mui:next Feb 5, 2019
@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 5, 2019

@eps1lon The rationale was highlighted in #14406 (comment). Now, the difference between babel-node vs using node doesn't outweigh the benefit of letting you pick what you think work best for the use case. I have reverted the changes. I have focused my attention on the logic, migrating some of the logic to the async / await syntax. I shouldn't have pushed force on your fork branch. I'm sorry. I'm happy to have looked at the code, the release script is important, better have more than one people having a close look at it. Eventually, we will release v4.0.0-alpha.0. People will report any problem.
Well done.

@eps1lon eps1lon deleted the core/single-copy-files branch February 13, 2019 19:33
@zannager zannager added the core Infrastructure work going on behind the scenes label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants