-
-
Notifications
You must be signed in to change notification settings - Fork 544
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
feat(dev-server): export package version #7305
Conversation
At present, users need to use the same version of "devDependencies": {
"@rspack/core": "0.7.5",
"@rspack/dev-server": "0.7.5"
} Have you encountered any issues? :D |
So getting the version from @rspack/core should do the job? I believe even if this is the case, since the 2 modules are separate they'd still need to expose their own version. |
@chenjiahan cc |
How about getting the version from import pkgJson from '@rspack/dev-server/package.json';
console.log(pkgJson.version); |
Agree with this. |
In this use case, there are different options of how ***@***.***/dev-server` is loaded:
1. Direct import at the top of the file
2. Injected as a reference (for user to be able to customise it), which is
dynamic.
For the second case, I'd need to have programmatic access of the version
through the API.
What I'm doing at the moment is something like this, which rather hacky
```
version(): string {
// Resolve version from the rspack-dev-server package.json
try {
const root = findRoot(this.rspackDevServerModulePath);
const packageJsonPath = join(root, 'package.json');
const packageJson = require(packageJsonPath);
return packageJson.version;
} catch (err) {
return 'unknown';
}
}
``
Ideally I want to be able to do something like:
```
version(): string {
return this.RspackDS.rspackDevServerVersion;
}
```
…On Thu, 25 Jul 2024 at 08:08, neverland ***@***.***> wrote:
I believe even if this is the case, since the 2 modules are separate
they'd still need to expose their own version.
Agree with this.
—
Reply to this email directly, view it on GitHub
<#7305 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPA4TXM4IU7IUQ2PO2BBADZOCP6XAVCNFSM6AAAAABLM3AVSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBZGYYTCMZTGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Export from @rspack/core exports webpack version as version, and @rspack/dev-server exports rspack dev server as version. This will be confusing, as I'd expect both modules to reference the respective package version. |
|
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
@leimonio I want to confirm how
|
In my case it's a bit more abstracted, and also relies on CommonJS in this way:
Basically, |
I see, so we need to add the version to the export class RspackDevServer extends WebpackDevServer {
static version = 'a.b.c';
} And users can access the version via: this.RspackDS = require('@rspack/dev-server').RspackDevServer;
console.log(this.RspackDS.version); |
13aace3
to
2653071
Compare
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 👍🏻
Summary
I was looking in a convenient way of getting the version of the
@rsapck/dev-server
similar to what is available in@rspack/core
Export version from
package.json
(similar to the@rspack/core
)Checklist