Page MenuHomePhabricator

Allow .vue files to be used in Gadgets
Closed, ResolvedPublicFeature

Description

ResourceLoader currently does not allow .vue files to be used in on-wiki modules (only .js, .css and .json) files. We want to allow .vue files, but we don't want to allow Less (via <style lang="less">) in these, only CSS. This is because we decided not to make Less available in user-authored modules in T56864#6153179, for fear that arbitrary user-authored Less code could take arbitrarily long to execute.

Because all the code for .vue file handling is currently in FileModule, some of it will need to be moved to Module, while preserving the ability of FileModule to allow Less to be used and the ability of WikiModule to forbid it.

  • Add a content model for .vue pages, with the same special treatment as .js pages
  • Move (most) .vue handling code from FileModule to Module
  • Allow .vue pages to be used in WikiModule
  • Do not allow Less to be used in WikiModule (but continue to allow it in FileModule)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 907557 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/extensions/Gadgets@master] [WIP] Support .vue files in packaged gadgets

https://gerrit.wikimedia.org/r/907557

Change 907556 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] [WIP] Support loading .vue pages in the MediaWiki namespace

https://gerrit.wikimedia.org/r/907556

This is because we decided not to make Less available in user-authored modules in T56864#6153179, for fear that arbitrary user-authored Less code could take arbitrarily long to execute.

Is this not also a concern for Vue, which must be transpiled to Javascript?

Izno changed the subtype of this task from "Task" to "Feature Request".Jul 24 2023, 3:15 PM

Upstream, Ace just last month added support for syntax highlighting vue (https://github.com/ajaxorg/ace/pull/5483).

For syntax highlighting in action=view mode though, Pygments doesn't yet support it. But they appear to be open to contribution - https://github.com/pygments/pygments/issues/2111

Upstream, Ace just last month added support for syntax highlighting vue (https://github.com/ajaxorg/ace/pull/5483).

Brilliant; I just made an Ace update last week for T342387 that includes this feature; it will go out this week, but isn't wired up (compare https://en.wikipedia.beta.wmflabs.org/wiki/User:Foo/Bar.js?action=edit which loads CodeEditor vs. https://en.wikipedia.beta.wmflabs.org/wiki/User:Foo/Bar.vue?action=edit which loads your wikitext editor, so there's a little more work needed to support nice editing of .vue on-wiki pages (the first checklist point in this task's list).

I wanted to note T373711: Add support for Scribunto, JavaScript, CSS, JSON and Vue to CodeMirror 6 which I hope to have tackled by MW 1.44, if not sooner. This is not a proposal to replace CodeEditor/Ace (yet), but CodeMirror does already has support for Vue. So I guess keep that in mind in your decision making.

Related but not for this task: Gerrit is already using CodeMirror 6, so it could be updated to use the Vue package which as you may have noticed currently lacks syntax highlighting.

Change #1106559 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/CodeEditor@master] Support Vue content model in CodeEditor

https://gerrit.wikimedia.org/r/1106559

Change #1106565 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/core@master] Support loading .vue pages in the MediaWiki namespace

https://gerrit.wikimedia.org/r/1106565

I've dusted off the old patches for Vue support. They are ready for review now. The patchdemo wiki shows the "Hello <name>" gadget running.

Also, @Diskdance has raised a PR for Vue support in Pygments for the syntax highlighting in action=view mode.

SD0001 moved this task from External to Inbox on the MediaWiki-ResourceLoader board.

Changing workboard as this involves changes to core ResourceLoader.

Change #907556 abandoned by Catrope:

[mediawiki/core@master] [WIP] Support loading .vue pages in the MediaWiki namespace

Reason:

Development continues at https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1106565

https://gerrit.wikimedia.org/r/907556

Also, @Diskdance has raised a PR for Vue support in Pygments for the syntax highlighting in action=view mode.

The PR is merged (thanks @Diskdance!) and Vue support is available in Pygments 2.19.0 (T383018).

Notes for testing the patches:

  1. Checkout https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1106565 and https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Gadgets/+/1108823
  2. Add to MediaWiki:Gadgets-definition:
* codextest [ResourceLoader | package | default | dependencies=vue,@wikimedia/codex | codexIcons=cdxIconTrash, cdxBazinga ] | codextest.js | codextest-main.vue | codextest-ChangeNameDialog.vue
  1. Create MediaWiki:Gadget-codextest.js with content from https://6d31ea4a6c.catalyst.wmcloud.org/wiki/MediaWiki:Gadget-codextest.js
  2. Create MediaWiki:Gadget-codextest-main.vue with content from https://6d31ea4a6c.catalyst.wmcloud.org/wiki/MediaWiki:Gadget-codextest-main.vue
  3. Create MediaWiki:Gadget-codextest-ChangeNameDialog.vue with content from https://6d31ea4a6c.catalyst.wmcloud.org/wiki/MediaWiki:Gadget-codextest-ChangeNameDialog.vue
  4. Now, Hello (name unknown)! appears near the top of every page, like at https://6d31ea4a6c.catalyst.wmcloud.org/wiki/Main_Page. Name can be set using the button.

Change #1106565 merged by jenkins-bot:

[mediawiki/core@master] Add content model for Vue and support loading via ResourceLoader

https://gerrit.wikimedia.org/r/1106565

Change #1106559 merged by jenkins-bot:

[mediawiki/extensions/CodeEditor@master] Support Vue content model in CodeEditor

https://gerrit.wikimedia.org/r/1106559

Change #1172005 had a related patch set uploaded (by SD0001; author: SD0001):

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Syntax highlight pages with Vue content model

https://gerrit.wikimedia.org/r/1172005

Change #1172005 merged by jenkins-bot:

[mediawiki/extensions/SyntaxHighlight_GeSHi@master] Syntax highlight pages with Vue content model

https://gerrit.wikimedia.org/r/1172005

Change #907557 merged by jenkins-bot:

[mediawiki/extensions/Gadgets@master] Support .vue files in packaged gadgets

https://gerrit.wikimedia.org/r/907557

For Tech News, please could someone suggest wording for the entry? I'm not sure what aspects are most useful to highlight, nor what to link to (documentation?). I imagine something like this, but need guidance on details and link(s):

Gadget and userscript developers can now use .vue files in their tools. This enables [...?....]. There is [[LINK? | documentation about this feature]].

Also, Timing-wise, will this be available on Monday (when we deliver Tech News), or "later this week"[with the deployment train]? -- If the latter, then you/we may want to postpone mentioning it in Tech News for a week, so that it is already live (and tested!) when folks read about it and they can immediately start using it. Please advise on that, too. Thanks!

Timing: parts of this are already available (one can create .vue pages), but it will become really functional “later this week”, when gadget support arrives (that part was merged today).

For the entry, more details:

Gadgets can now include .vue files. This makes it easier to develop modern user interfaces using Vue.js, in particular using Codex, the official design system of Wikimedia. Codex icons are now also available. T340460 T311099

The documentation on mediawiki.org has been updated, I don’t know if it needs to be linked (the exact syntax is described there but is out of scope for the Tech News entry).