From e7bc5cdef9a2c7cbc2d2cf2e638e4467448bf3b8 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Sun, 26 Apr 2026 14:30:14 +0200 Subject: [PATCH] Convert require to import: rjquery, timeslider, underscore - Convert const X = require('Y') to import X from 'Y.js' - Convert const {A, B} = require('Y') to import {A, B} from 'Y.js' - Add .js extensions to relative imports - Keep external packages without .js (e.g., 'tinycon/tinycon', 'underscore') - Convert exports.X = Y to export {X} - Convert module.exports to export default Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/static/js/rjquery.ts | 6 ++++-- src/static/js/timeslider.ts | 16 ++++++++-------- src/static/js/underscore.ts | 4 +++- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/static/js/rjquery.ts b/src/static/js/rjquery.ts index 167e96090..9a28da15f 100644 --- a/src/static/js/rjquery.ts +++ b/src/static/js/rjquery.ts @@ -1,6 +1,8 @@ // @ts-nocheck 'use strict'; // Provides a require'able version of jQuery without leaking $ and jQuery; -window.$ = require('./vendors/jquery'); +import $ from './vendors/jquery.js'; +window.$ = $; const jq = window.$.noConflict(true); -exports.jQuery = exports.$ = jq; + +export {jq as jQuery, jq as $}; diff --git a/src/static/js/timeslider.ts b/src/static/js/timeslider.ts index d0e45973f..93497e038 100644 --- a/src/static/js/timeslider.ts +++ b/src/static/js/timeslider.ts @@ -25,13 +25,13 @@ // These jQuery things should create local references, but for now `require()` // assigns to the global `$` and augments it with plugins. -require('./vendors/jquery'); +import './vendors/jquery.js'; -import {randomString, Cookies} from "./pad_utils"; -const hooks = require('./pluginfw/hooks'); -import padutils from './pad_utils' -const socketio = require('./socketio'); -import html10n from '../js/vendors/html10n' +import {randomString, Cookies} from "./pad_utils.js"; +import hooks from './pluginfw/hooks.js'; +import padutils from './pad_utils.js' +import socketio from './socketio.js'; +import html10n from '../js/vendors/html10n.js' let token, padId, exportLinks, socket, changesetLoader, BroadcastSlider; let cp = ''; const playbackSpeedCookie = 'timesliderPlaybackSpeed'; @@ -222,5 +222,5 @@ const handleClientVars = (message) => { }); }; -exports.baseURL = ''; -exports.init = init; +export const baseURL = ''; +export {init}; diff --git a/src/static/js/underscore.ts b/src/static/js/underscore.ts index 79a3e8e7f..c9ec7e0f7 100644 --- a/src/static/js/underscore.ts +++ b/src/static/js/underscore.ts @@ -1,4 +1,6 @@ // @ts-nocheck 'use strict'; -module.exports = require('underscore'); +import _ from 'underscore'; + +export default _;