Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #2880013: Add command to check if .es6.js has been transpiled
Problem/Motivation
When transpiling JS files we sensibly add a comment to thew top of each file which tells people not to change the file and which file to change.
Unfortunately,
yarn run build:js -- --file ./misc/active-link.es6.js
and
yarn run build:js -- --file misc/active-link.es6.js
and
yarn run build:js -- --file ~/dev/sites/drupal8alt.dev/core/misc/active-link.es6.js
The latter results in the current a diff like:
diff --git a/core/misc/active-link.js b/core/misc/active-link.js
index b9700a1..4fb364d 100644
--- a/core/misc/active-link.js
+++ b/core/misc/active-link.js
@@ -1,6 +1,6 @@
/**
* DO NOT EDIT THIS FILE.
-* All changes should be applied to ./misc/active-link.es6.js
+* All changes should be applied to /Users/alex/dev/sites/drupal8alt.dev/core/misc/active-link.es6.js
* See the following change record for more information,
* https://www.drupal.org/node/2873849
* @preserve
Proposed resolution
Remove file path. It is not that helpful. Also https://www.drupal.org/node/2873849 is not the correct CR - https://www.drupal.org/node/2815083 is.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#10 | 2880560-9.patch | 72.35 KB | alexpott |
#8 | c20170523_180727.png | 23.27 KB | droplet |
#2 | 2880560-2.patch | 77.43 KB | alexpott |
Comments
Comment #2
alexpottComment #3
alexpottHere's the important change. The rest of the patch is just compiled JS changing.
Comment #4
droplet CreditAttribution: droplet commentedI think we can remove this line.
First, our ES6 always next to non-ES6.
Second, if you're the first time to contribute. It's worth to read #2873849 first. To understand the whole build process. (You're not just applying changes to ES6, but has build process)
Third, gzipped, smaller file size, hehe
Comment #5
alexpott@droplet the line is there to help people learn - you know how things are working so it seems obvious and redundant. But this line is pointing to #2873849 so it just helps.
Comment #6
droplet CreditAttribution: droplet commented@alexpott,
No. If you understand nothing, you read the sentences and edit ES6 and then `git diff`. Boom!
BUT, if we didn't provide anything there, you may guess or should read #2873849 to understand.
We have no `src` and `build` dir. So we need not provide a full path to help to discover the file.
It's better linking to https://www.drupal.org/node/2815083 instead
Ideally, we should create a new Docs. We need not explain background story that why we did it. Just instructions to patch.
Comment #7
droplet CreditAttribution: droplet commentedJust keep this:
`DO NOT EDIT THIS FILE.\n See the following change record for more information,\nhttps://www.drupal.org/node/2815083\n@preserve`
Comment #8
droplet CreditAttribution: droplet commentedeven better (SPACE won't increasing file sizes a lot):
I know it's a bit crazy :p
As experienced developer, I won't start from LINE1 (won't start from comments, usually it collapsed auto)
Comment #9
droplet CreditAttribution: droplet commentedComment #10
alexpott@droplet ok I think you are right - including the corresponding file is not that helpful because in order to know what to edit and then what commands to run you should read https://www.drupal.org/node/2815083 (Nice catch)
So let's remove it and swap the CR link.
No interdiff because it would be twice the size of the patch file.
Comment #11
alexpottHere's the only non-automated change in this patch.
Comment #12
droplet CreditAttribution: droplet commentedGo Go Go!
Comment #13
alexpottAdding the filepath to the comment was @drpal's and my idea in #2818825-10: Rename all JS files to *.es6.js and compile them - we got it wrong. But adding the comment was a good idea.
Comment #14
GrandmaGlassesRopeManAlright. I think this is actually much better. +1 for this :)
Comment #15
catchCommitted/pushed to 8.4.x, thanks!