Skip to content

Commit

Permalink
🐛 CoffeeScript: Fix CoffeeScript package's loading problems that appe…
Browse files Browse the repository at this point in the history
…ared after facilitating ESBuild
  • Loading branch information
CosmoMyzrailGorynych committed May 19, 2024
1 parent 7c970d6 commit f65de35
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/node_requires/exporter/scriptableProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/node_requires/exporter/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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 =>
scripts.reduce((acc, script) => {
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;
Expand Down
4 changes: 2 additions & 2 deletions src/node_requires/resources/projects/convertLanguage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const coffeescript = require('coffeescript');
const compileCoffee = require('coffeescript').CoffeeScript.compile;
const coffeescriptSettings = {
bare: true,
sourcemaps: false
Expand All @@ -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)
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/riotTags/editors/script-editor.tag
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
4 changes: 2 additions & 2 deletions src/riotTags/shared/scriptables/code-editor-scriptable.tag
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down

0 comments on commit f65de35

Please sign in to comment.