Repository navigation
feat: add {{packageVersion}} as template variable - #1604
Conversation
…te and sourcesTemplate
✅ Deploy Preview for creative-fairy-df92c4 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
| @@ -39,6 +40,7 @@ export async function zip(config?: InlineConfig): Promise<string[]> { | |||
| '{{version}}', | |||
| output.manifest.version_name ?? output.manifest.version, | |||
There was a problem hiding this comment.
As you can see here, the {{version}} template variable will already use the manifest.version_name if it exists... And as long as you haven't manually set the manifest's version property, it will be automatically pulled from the package.json:
There was a problem hiding this comment.
No, it doesn't.
I use custom artifactTemplate and sourcesTemplate:
zip: {
excludeSources: ['icons/**', 'screenshots/**', '*.yml'],
artifactTemplate: '{{name}}-v{{version}}-{{browser}}.zip',
sourcesTemplate: '{{name}}-v{{version}}-sources.zip',
},
Package version is 1.0.0-beta.1 and I don't set the manifest's version property manually. But the resulting zip files are named:
myextension-v1.0.0-beta.1-chrome.zip
myextension-v1.0.0-firefox.zip
myextension-v1.0.0-sources.zip
-beta.1 is not included in the firefox and sources zip!
EDIT: this is probably because Firefox does not support version_name and hence when building/zipping for Firefox, version_name is not used?
EDIT2: Yep, I was right:
wxt/packages/wxt/src/core/utils/manifest.ts
Lines 115 to 119 in 14d4aa2
There was a problem hiding this comment.
There was a problem hiding this comment.
If you are OK with a breaking change, maybe it would be more consistent to to have 3 template variables for the version:
{{version}}--> strictly usemanifest.version{{versionName}}--> usemanifest.version_nameif available or fallback tomanifest.version(current behaviour of{{version}}){{packageVersion}}--> always usepackage.version
The behaviour of {{version}} would change but this feels more consistent.
What do you say?
There was a problem hiding this comment.
Eventually that's probably a good idea. If you want this PR merged soon, make the breaking change in the breaking change in a second PR and I'll add it to the next major release whenever that happens.
If it's not urgent, you are welcome to update this PR with that change!
There was a problem hiding this comment.
I have updated the PR according to your suggestions. I hope it is OK.
I will create a separate PR for the breaking change later.
@wxt-dev/analytics
@wxt-dev/auto-icons
@wxt-dev/i18n
@wxt-dev/browser
@wxt-dev/module-react
@wxt-dev/module-solid
@wxt-dev/module-svelte
@wxt-dev/module-vue
@wxt-dev/storage
@wxt-dev/unocss
@wxt-dev/webextension-polyfill
wxt
commit: |
|
Looks like the formatting check failed. Run |
|
It should pass now. Sorry... |
Haha, you're good! |
|
Thanks for helping make WXT better! |
Overview
This PR adds {{packageVersion}} as an additional template variable to artifactTemplate and sourcesTemplate.
Currently only {{version}} can be used. However, when building for Firefox, a package version such as 1.0.0-beta.1 is reduced to 1.0.0 because Firefox does not allow suffixes in the version in the manifest file. Therefore, the version numbers in the file names of the zip files for Firefox differ from the version number in the file name for Chrome, e.g.:
With this PR and when using {{packageVersion}} instead of {{version}}, the version in the file names is the same:
Manual Testing
Change your package version to 1.0.0-beta.1 .
Set a custom artifactTemplate and sourcesTemplate in your wxt.config.ts:
Run
wxt zip -b firefox.The resulting zip files should contain the package version
1.0.0-beta.1in the file name.Related Issue
N/A
I think this PR might be beneficial for people like me who want to see the package version number in the filename.