-
Notifications
You must be signed in to change notification settings - Fork 203
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
Add attribute to the body/head element with Guess.js version #228
Comments
Hi Minko! I don't have much experience but I would like to work on this one. Do you have any approach to achieve this? |
This features involves the following two steps:
For the first step there are two main approaches that seem feasible. The first one is adding a placeholder in any of the runtime script templates and filling it in the Now, in the runtime script we should add an attribute to an element. The tricky part is that we need to add it to an element that we're certain it exists. We can call this attribute |
Thank you for the answer! I'm taking a time to dig into the problem and have a better understanding. Let me put an example to see if I understood. Lets say we add a version.ts file under guess/packages/guess-parser/src. This file contains something like: const guess_version = ''; Also we modify the npm run build script in the main package.json file to something like: "build": "fill-placeholder && lerna run build". Fill-placeholder will replace the guess-version value in version.ts file. Does this approximate to your solution, Minko? Thank you! |
I'm sorry, I was wrong. The placeholder should go in /packages/guess-webpack/src/runtime/runtime.ts. |
@brunob15, yes, this sounds like a good plan to me! You're right about the package, it should be in |
Great, thank you for your answer! I'll try to come back with a solution. |
@brunob15 are you still working on this issue? We can use the following method,
import { version as guess_version } from '../../package.json';
...
export const version = guess_version;
import { guess, initialize as initializeGuess, version } from './guess';
...
export const initialize = (
...
if (typeof document !== 'undefined' && typeof document.body !== 'undefined'){
document.body.setAttribute('guess-version', version);
} @mgechev, What do you think? Should I open a pull request? |
@skyme5 No, I'm not. |
Excuse me for the delay. We did some experiments in HTTPArchive to find who's currently using Guess.js. Looks like crawlers are executing JavaScript. They can look up the Having: __GUESS__ = {
p() {
// ...
},
version: 'X.Y.Z'
}; Would be great. |
No description provided.
The text was updated successfully, but these errors were encountered: