From f65de35c3edef35e05da9ecfe592b10359e37b6b Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych Date: Sun, 19 May 2024 16:23:33 +0300 Subject: [PATCH] :bug: CoffeeScript: Fix CoffeeScript package's loading problems that appeared after facilitating ESBuild --- src/node_requires/exporter/scriptableProcessor.ts | 4 ++-- src/node_requires/exporter/scripts.ts | 4 ++-- src/node_requires/resources/projects/convertLanguage.ts | 4 ++-- src/riotTags/editors/script-editor.tag | 4 ++-- src/riotTags/shared/scriptables/code-editor-scriptable.tag | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/node_requires/exporter/scriptableProcessor.ts b/src/node_requires/exporter/scriptableProcessor.ts index 16740c4b2..22c022d31 100644 --- a/src/node_requires/exporter/scriptableProcessor.ts +++ b/src/node_requires/exporter/scriptableProcessor.ts @@ -7,7 +7,7 @@ import {getName, getById} from '../resources'; import {getModulePathByName, loadModuleByName} from './../resources/modules'; import {join} from 'path'; import {embedStaticBehaviors} from './behaviors'; -const coffeeScript = require('coffeescript'); +const compileCoffee = require('coffeescript').CoffeeScript.compile; const typeScript = require('sucrase').transform; import {compile, resetSafeId} from '../catnip/compiler'; @@ -93,7 +93,7 @@ const getBaseScripts = function (entity: IScriptable, project: IProject): Script let {code} = event; try { // Apply converters to the user's code first if (project.language === 'coffeescript') { - code = coffeeScript.compile((code as string), coffeeScriptOptions); + code = compileCoffee((code as string), coffeeScriptOptions); } else if (project.language === 'catnip') { code = compile(code as BlockScript, { resourceId: entity.uid, diff --git a/src/node_requires/exporter/scripts.ts b/src/node_requires/exporter/scripts.ts index 7016e012a..ff2c02238 100644 --- a/src/node_requires/exporter/scripts.ts +++ b/src/node_requires/exporter/scripts.ts @@ -1,7 +1,7 @@ import {ExporterError, highlightProblem} from './ExporterError'; import {coffeeScriptOptions} from './scriptableProcessor'; -const coffeeScript = require('coffeescript'); +const compileCoffee = require('coffeescript').CoffeeScript.compile; const typeScript = require('sucrase').transform; export const stringifyScripts = (scripts: IScript[]): string => @@ -9,7 +9,7 @@ export const stringifyScripts = (scripts: IScript[]): string => let code; try { // Apply converters to the user's code first code = script.language === 'coffeescript' ? - coffeeScript.compile(script.code, coffeeScriptOptions) : + compileCoffee(script.code, coffeeScriptOptions) : typeScript(script.code, { transforms: ['typescript'] }).code; diff --git a/src/node_requires/resources/projects/convertLanguage.ts b/src/node_requires/resources/projects/convertLanguage.ts index e0194d051..0a70e599c 100644 --- a/src/node_requires/resources/projects/convertLanguage.ts +++ b/src/node_requires/resources/projects/convertLanguage.ts @@ -1,4 +1,4 @@ -const coffeescript = require('coffeescript'); +const compileCoffee = require('coffeescript').CoffeeScript.compile; const coffeescriptSettings = { bare: true, sourcemaps: false @@ -18,7 +18,7 @@ export const convertCoffeeToJs = (): void => { for (const event of (asset as IScriptable).events) { changeset.push({ event, - code: coffeescript.compile(event.code, coffeescriptSettings) + code: compileCoffee(event.code, coffeescriptSettings) }); } } diff --git a/src/riotTags/editors/script-editor.tag b/src/riotTags/editors/script-editor.tag index eca3f0a86..19d6bed64 100644 --- a/src/riotTags/editors/script-editor.tag +++ b/src/riotTags/editors/script-editor.tag @@ -61,14 +61,14 @@ script-editor.aPanel.aView.flexfix this.opts.ondone(this.asset); }; - const coffeescript = require('coffeescript'); + const compileCoffee = require('coffeescript').CoffeeScript.compile; const checkProblemsDebounced = window.debounce(() => { if (!this.codeEditor || this.asset.language !== 'coffeescript') { return; } const oldProblem = this.problem; try { - coffeescript.compile(this.codeEditor.getValue(), { + compileCoffee(this.codeEditor.getValue(), { bare: true, sourcemaps: false }); diff --git a/src/riotTags/shared/scriptables/code-editor-scriptable.tag b/src/riotTags/shared/scriptables/code-editor-scriptable.tag index fe0bd8e59..13e0122d6 100644 --- a/src/riotTags/shared/scriptables/code-editor-scriptable.tag +++ b/src/riotTags/shared/scriptables/code-editor-scriptable.tag @@ -34,14 +34,14 @@ code-editor-scriptable.relative.wide.tall.flexcol this.language = window.currentProject.language || 'typescript'; this.allEvents = eventsAPI.events; - const coffeescript = require('coffeescript'); + const compileCoffeScript = require('coffeescript').CoffeeScript.compile; const checkProblemsDebounced = window.debounce(() => { if (!this.codeEditor || this.language !== 'coffeescript') { return; } const oldProblem = this.problem; try { - coffeescript.compile(this.codeEditor.getValue(), { + compileCoffeScript(this.codeEditor.getValue(), { bare: true, sourcemaps: false });