-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: fix undefined process in package #1997
Conversation
@@ -164,8 +164,7 @@ | |||
"source-map-explorer": "^2.5.3", | |||
"stylelint": "^15.11.0", | |||
"ts-jest": "^29.2.5", | |||
"typescript": "^5.7.3", | |||
"webpack": "^5.98.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to install it explicitly
ad5f2e1
to
602fd97
Compare
@@ -141,7 +143,7 @@ export const autocompleteOnEnterSetting: SettingProps = { | |||
export const interfaceVersionInfoField: SettingsInfoFieldProps = { | |||
title: i18n('settings.about.interfaceVersionInfoField.title'), | |||
type: 'info', | |||
content: process.env.UI_VERSION, | |||
content: packageJson.version, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried sth like window.ui_version? the same way it is used for react_app_disable_checks
Still feel that using package.json directly may have pitfalls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried index.html
, the problem is that webpack.DefinePlugin
does not expose vars to html files, so we can use them in js, but not in index.html
(but all envs passed in command or taken from .env
file work fine).
// Add DefinePlugin to expose just the version | ||
config.plugins.push( | ||
new webpack.DefinePlugin({ | ||
'process.env.UI_VERSION': JSON.stringify(packageJson.version), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's wrong with this approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.env
values are embedded in build, so in build I have
version: process.env.UI_VERSION
-> version: 8.11.0
However, when we use it as a package, we have only process.env.UI_VERSION
in our code, when we import it and try to open in UI we receive process
is not defined error, no variables are exposed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Could you try this approach? https://github.com/ydb-platform/ydb-embedded-ui/pull/2005/files |
Please, describe, how it should work in case of package? There is no vars from |
You right - it wont work for package Maybe
would work? Here is some discussion on this topic https://stackoverflow.com/questions/9153571/is-there-a-way-to-get-the-version-from-the-package-json-file-in-node-js-code The idea of exposing entire package.json intuitively feels unsecure However, our code is open-source and package.json is already visible in github to everyone - so its not a problem Could we give it the last try with import {version} from './package.json'; and if it wont work - proceed with requiring the whole package.json |
There is another error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, at least we tried :_)
When ydb-embedded-ui is used as package, there is an error, that
process
is not defined. That's why I import package json directlyCI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️1
⏭️ Skipped Tests (1)
Bundle Size: ✅
Current: 80.81 MB | Main: 80.81 MB
Diff: 0.15 KB (-0.00%)
✅ Bundle size unchanged.
ℹ️ CI Information