ESMify: Use .mjs for Zotero modules everywhere

This commit is contained in:
Abe Jellinek 2025-07-01 14:06:15 -04:00
parent b2bd862271
commit f21ea96b4f
3 changed files with 9 additions and 4 deletions

View file

@ -34,6 +34,7 @@ function generateESMURIMap(jsm_map) {
function isESMifiedSlow(resourceURI) {
if (resourceURI.endsWith('.jsm')) {
console.log(resourceURI.includes('/zotero/'))
if (resourceURI.includes('/zotero/')) {
return { result: true, jsms: [resourceURI.replace('.jsm', '.mjs')] };
} else {

View file

@ -664,12 +664,12 @@ def try_rename_components_conf(command_context, path, jsm_name, esm_name):
def esmify_name(name):
return re.sub(r"\.(jsm|js|jsm\.js)$", ".sys.mjs", name)
return re.sub(r"\.(jsm|js|jsm\.js)$", ".mjs", name)
def esmify_path(jsm_path):
jsm_name = jsm_path.name
esm_name = re.sub(r"\.(jsm|js|jsm\.js)$", ".sys.mjs", jsm_name)
esm_name = re.sub(r"\.(jsm|js|jsm\.js)$", ".mjs", jsm_name)
esm_path = jsm_path.parent / esm_name
return esm_path
@ -713,7 +713,7 @@ def find_jsm_uri(jsm_path):
def rename_single_file(command_context, vcs_utils, jsm_path, summary):
"""Rename `jsm_path` to .sys.mjs, and fix references to the file in build
"""Rename `jsm_path` to .mjs, and fix references to the file in build
and test definitions."""
def info(text):

View file

@ -68,7 +68,11 @@ function isString(node) {
const jsmExtPattern = /\.(jsm|js|jsm\.js)$/;
function esmifyExtension(path) {
return path.replace(jsmExtPattern, ".sys.mjs");
if (path.includes('/zotero/')) {
return path.replace(jsmExtPattern, ".mjs");
} else {
return path.replace(jsmExtPattern, ".sys.mjs");
}
}
// Given possible member expression, return the list of Identifier nodes in