Skip to content
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

Can't package language extension #826

Closed
blakegearin opened this issue Feb 3, 2023 · 5 comments · Fixed by #839
Closed

Can't package language extension #826

blakegearin opened this issue Feb 3, 2023 · 5 comments · Fixed by #839
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@blakegearin
Copy link

$ vsce package
 ERROR  Manifest needs either a 'main' or 'browser' property, given it has a 'activationEvents' property.

My package.json doesn't have activationEvents as it's a language extension generated with Yo Code

Looks like the recent #809 is causing this to occur because of new implicit activationEvents checking (https://github.com/microsoft/vscode-vsce/blob/main/src/package.ts#L1214-L1244)

Unless I'm mistaken, a main or browser property isn't needed for this type of extension

Could address with some logic like this:

const hasLanguages = manifest.contributes?.languages;
const hasImplicitActivationEvents =
		manifest.contributes?.commands ||
		manifest.contributes?.authentication ||
		manifest.contributes?.customEditors ||
		manifest.contributes?.views;
...
if (
	!(hasLanguages && !hasActivationEvents) &&
	(
		hasActivationEvents || 
		(
			(engineVersion === '*' || semver.satisfies(parsedEngineVersion, '>=1.74', { includePrerelease: true })) &&
			hasImplicitActivationEvents
		)
	)
) {
	if (!hasMain && !hasBrowser) {
		throw new Error(
			"Manifest needs either a 'main' or 'browser' property, given it has a 'activationEvents' property."
		);
	}
}
@blakegearin
Copy link
Author

Confirmed that downgrading to 2.16.0 allows vsce package to succeed.

@samubarb
Copy link

samubarb commented Feb 6, 2023

Hi, I have the same issue with v2.17.0 and a language extension. Downgrading vsce to v2.16.0 solved the publication issue also for me, thanks @blakegearin

It seems like also pure language contributions have at least one implicit activationEvents which is onLanguage. It may not play nice with the entrypoint ("main"/"browser") constraint mechanism.

@joaomoreno joaomoreno self-assigned this Feb 21, 2023
@joaomoreno joaomoreno added the bug Issue identified by VS Code Team member as probable bug label Feb 21, 2023
@joaomoreno joaomoreno added this to the February 2023 milestone Feb 21, 2023
joaomoreno added a commit that referenced this issue Feb 21, 2023
* remove pre-commit hooks

* language contributions shouldn't force an entrypoint

fixes #826
@ulugbekna ulugbekna self-assigned this Feb 23, 2023
@ulugbekna
Copy link
Contributor

For verification, I did:

  • I created a language extension with yo code -- the manifest doesn't have activationEvents
  • running node ../vscode-vsce/vsce package packages the extension successfully

@ulugbekna ulugbekna added the verified Verification succeeded label Feb 23, 2023
@ulugbekna ulugbekna removed their assignment Feb 23, 2023
@youqad
Copy link

youqad commented Feb 24, 2023

Hi! Unfortunately, I still have the same issue as OP with @vscode/vsce version 2.17.0 and VSCode 1.75.0 on macOS Ventura 13.1 (I spent the whole night trying to figure out where was the problem), for a similar language extension: https://github.com/youqad/dex-syntax-highlighting

vsce package or vsce publish both yield the error

 ERROR  Manifest needs either a 'main' or 'browser' property, given it has a 'activationEvents' property.

youqad added a commit to youqad/dex-syntax-highlighting that referenced this issue Feb 24, 2023
@youqad
Copy link

youqad commented Feb 24, 2023

Oh sorry, updating @vscode/vsc to the very lastest 2.18.0 now solves the issue, thank you @joaomoreno and @ulugbekna ! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants