refactor!: stop using babel-node

This should improve call stacks when debugging.

BREAKING CHANGE: Some files have been renamed from '.js' to '.mjs'
This commit is contained in:
Christopher Willis-Ford 2024-10-28 10:41:37 -07:00
parent c7cb44a567
commit 44c4b97581
16 changed files with 41 additions and 41 deletions

View file

@ -22,14 +22,14 @@ There are two situations in which we create manual PRs to update translations:
### Adding a language ### Adding a language
* [ ] Edit `src/supported-locales.js`: * [ ] Edit `src/supported-locales.mjs`:
* [ ] Add entry for the language in the `locales` const * [ ] Add entry for the language in the `locales` const
* [ ] Check if language is right-to-left. If so: * [ ] Check if language is right-to-left. If so:
* Add entry in `rtlLocales` * Add entry in `rtlLocales`
* [ ] Check if the new language uses a country code * [ ] Check if the new language uses a country code
* Check [https://www.transifex.com/explore/languages](https://www.transifex.com/explore/languages). If the language has a country code: * Check [https://www.transifex.com/explore/languages](https://www.transifex.com/explore/languages). If the language has a country code:
* [ ] Edit `src/supported-locales.js`: * [ ] Edit `src/supported-locales.mjs`:
* Add new entry to `localeMap`. Format is `'<W3C HTML browser locale string>': '<Transifex ICU locale string>'` * Add new entry to `localeMap`. Format is `'<W3C HTML browser locale string>': '<Transifex ICU locale string>'`
* [ ] Edit `.tx/config`: * [ ] Edit `.tx/config`:
* Add to the `lang_map` list. Format is `<Transifex ICU locale string>:<W3C HTML browser locale string>` * Add to the `lang_map` list. Format is `<Transifex ICU locale string>:<W3C HTML browser locale string>`
@ -42,14 +42,14 @@ There are two situations in which we create manual PRs to update translations:
* [ ] Check if locale is in `react-intl` * [ ] Check if locale is in `react-intl`
* Look in [https://unpkg.com/react-intl/locale-data/](https://unpkg.com/react-intl/locale-data/) * Look in [https://unpkg.com/react-intl/locale-data/](https://unpkg.com/react-intl/locale-data/)
* If not in `react-intl`: * If not in `react-intl`:
* [ ] Edit `src/supported-locales.js`: * [ ] Edit `src/supported-locales.mjs`:
* In `customLocales`, add entry with parent set to a `react-intl` locale * In `customLocales`, add entry with parent set to a `react-intl` locale
* [ ] Edit `src/index.js`: * [ ] Edit `src/index.js`:
* In `localeData`, add entry for parent locale * In `localeData`, add entry for parent locale
* [ ] Update translations per the "Updating translations" section above * [ ] Update translations per the "Updating translations" section above
* [ ] Confirm that we see changes to: * [ ] Confirm that we see changes to:
* [ ] `src/supported-locales.js` * [ ] `src/supported-locales.mjs`
* [ ] `src/index.js` * [ ] `src/index.js`
* [ ] `.tx/config` (if language needed a new locale) * [ ] `.tx/config` (if language needed a new locale)
* [ ] Multiple files like `editor/<resource>/<lang code>.json` * [ ] Multiple files like `editor/<resource>/<lang code>.json`

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview

View file

@ -10,31 +10,31 @@
}, },
"scripts": { "scripts": {
"build": "npm run clean && npm run build:data && webpack --progress --colors --bail", "build": "npm run clean && npm run build:data && webpack --progress --colors --bail",
"build:data": "babel-node scripts/build-data", "build:data": "node scripts/build-data.mjs",
"clean": "rimraf ./dist ./locales && mkdirp dist locales", "clean": "rimraf ./dist ./locales && mkdirp dist locales",
"lint": "npm run lint:js && npm run lint:json", "lint": "npm run lint:js && npm run lint:json",
"lint:js": "eslint . --ext .js", "lint:js": "eslint . --ext .js,.mjs,.cjs",
"lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor", "lint:json": "jshint -e .json www editor/blocks editor/extensions editor/interface editor/paint-editor",
"prepare": "husky install", "prepare": "husky install",
"pull:blocks": "babel-node scripts/tx-pull-editor scratch-editor blocks ./editor/blocks/", "pull:blocks": "node scripts/tx-pull-editor.mjs scratch-editor blocks ./editor/blocks/",
"pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface", "pull:editor": "npm run pull:blocks && npm run pull:extensions && npm run pull:paint && npm run pull:interface",
"pull:extensions": "babel-node scripts/tx-pull-editor scratch-editor extensions ./editor/extensions/", "pull:extensions": "node scripts/tx-pull-editor.mjs scratch-editor extensions ./editor/extensions/",
"pull:help": "npm run pull:help:names && npm run pull:help:articles", "pull:help": "npm run pull:help:names && npm run pull:help:articles",
"pull:help:articles": "./scripts/tx-pull-help-articles.js", "pull:help:articles": "./scripts/tx-pull-help-articles.js",
"pull:help:names": "./scripts/tx-pull-help-names.js", "pull:help:names": "./scripts/tx-pull-help-names.js",
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/", "pull:interface": "node scripts/tx-pull-editor.mjs scratch-editor interface ./editor/interface/",
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/", "pull:paint": "node scripts/tx-pull-editor.mjs scratch-editor paint-editor ./editor/paint-editor/",
"pull:www": "babel-node scripts/tx-pull-www ./www", "pull:www": "node scripts/tx-pull-www.mjs ./www",
"push:help": "./scripts/tx-push-help.js", "push:help": "./scripts/tx-push-help.mjs",
"sync:help": "npm run push:help && npm run pull:help", "sync:help": "npm run push:help && npm run pull:help",
"test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json", "test": "npm run lint:js && npm run validate:editor && npm run validate:www && npm run build && npm run lint:json",
"update": "scripts/update-translations.sh", "update": "scripts/update-translations.sh",
"validate:blocks": "babel-node scripts/validate-translations ./editor/blocks/", "validate:blocks": "node scripts/validate-translations.mjs ./editor/blocks/",
"validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint", "validate:editor": "npm run validate:blocks && npm run validate:extensions && npm run validate:interface && npm run validate:paint",
"validate:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs", "validate:extensions": "node scripts/validate-translations.mjs ./editor/extensions/ && node scripts/validate-extension-inputs.mjs",
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/", "validate:interface": "node scripts/validate-translations.mjs ./editor/interface/",
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/", "validate:paint": "node scripts/validate-translations.mjs ./editor/paint-editor/",
"validate:www": "babel-node scripts/validate-www ./www" "validate:www": "node scripts/validate-www.mjs ./www"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View file

@ -42,7 +42,7 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import {sync as mkdirpSync} from 'mkdirp'; import {sync as mkdirpSync} from 'mkdirp';
import defaultsDeep from 'lodash.defaultsdeep'; import defaultsDeep from 'lodash.defaultsdeep';
import locales from '../src/supported-locales.js'; import locales from '../src/supported-locales.mjs';
const MSGS_DIR = './locales/'; const MSGS_DIR = './locales/';
mkdirpSync(MSGS_DIR); mkdirpSync(MSGS_DIR);

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview
@ -29,8 +29,8 @@ if (!process.env.TX_TOKEN || args.length < 3) {
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import {txPull} from '../lib/transifex.js'; import {txPull} from '../lib/transifex.js';
import {validateTranslations} from '../lib/validate.js'; import {validateTranslations} from '../lib/validate.mjs';
import locales, {localeMap} from '../src/supported-locales.js'; import locales, {localeMap} from '../src/supported-locales.mjs';
import {batchMap} from '../lib/batch.js'; import {batchMap} from '../lib/batch.js';
// Globals // Globals

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview
@ -31,7 +31,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import mkdirp from 'mkdirp'; import mkdirp from 'mkdirp';
import {txPull, txResources} from '../lib/transifex.js'; import {txPull, txResources} from '../lib/transifex.js';
import locales, {localeMap} from '../src/supported-locales.js'; import locales, {localeMap} from '../src/supported-locales.mjs';
import {batchMap} from '../lib/batch.js'; import {batchMap} from '../lib/batch.js';
// Globals // Globals

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview
@ -9,7 +9,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import async from 'async'; import async from 'async';
import assert from 'assert'; import assert from 'assert';
import locales from '../src/supported-locales.js'; import locales from '../src/supported-locales.mjs';
// Globals // Globals
const JSON_DIR = path.join(process.cwd(), '/editor/extensions'); const JSON_DIR = path.join(process.cwd(), '/editor/extensions');

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview
@ -8,7 +8,7 @@
const args = process.argv.slice(2); const args = process.argv.slice(2);
const usage = ` const usage = `
Validate translation json. Usage: Validate translation json. Usage:
babel-node validate_translations.js path node validate_translations.mjs path
path: where to find the downloaded json files path: where to find the downloaded json files
`; `;
// Fail immediately if the TX_TOKEN is not defined // Fail immediately if the TX_TOKEN is not defined
@ -19,8 +19,8 @@ if (args.length < 1) {
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import async from 'async'; import async from 'async';
import {validateTranslations} from '../lib/validate.js'; import {validateTranslations} from '../lib/validate.mjs';
import locales from '../src/supported-locales.js'; import locales from '../src/supported-locales.mjs';
// Globals // Globals
const JSON_DIR = path.resolve(args[0]); const JSON_DIR = path.resolve(args[0]);

View file

@ -1,4 +1,4 @@
#!/usr/bin/env babel-node #!/usr/bin/env node
/** /**
* @fileoverview * @fileoverview
@ -8,7 +8,7 @@
const args = process.argv.slice(2); const args = process.argv.slice(2);
const usage = ` const usage = `
Validate translation json. Usage: Validate translation json. Usage:
babel-node validate_www.js path node validate_www.mjs path
path: root folder for all the www resource folders path: root folder for all the www resource folders
`; `;
if (args.length < 1) { if (args.length < 1) {
@ -19,8 +19,8 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import glob from 'glob'; import glob from 'glob';
import async from 'async'; import async from 'async';
import {validateTranslations} from '../lib/validate.js'; import {validateTranslations} from '../lib/validate.mjs';
import locales from '../src/supported-locales.js'; import locales from '../src/supported-locales.mjs';
// Globals // Globals
const WWW_DIR = path.resolve(args[0]); const WWW_DIR = path.resolve(args[0]);

View file

@ -1,3 +0,0 @@
import localeData from './locale-data.js';
import locales, {localeMap, isRtl} from './supported-locales.js';
export {locales as default, localeData, localeMap, isRtl};

3
src/index.mjs Normal file
View file

@ -0,0 +1,3 @@
import localeData from './locale-data.mjs';
import locales, {localeMap, isRtl} from './supported-locales.mjs';
export {locales as default, localeData, localeMap, isRtl};

View file

@ -72,7 +72,7 @@ import xh from './locale-data/xh';
import zh from './locale-data/zh'; import zh from './locale-data/zh';
import zu from './locale-data/zu'; import zu from './locale-data/zu';
import {customLocales} from './supported-locales.js'; import {customLocales} from './supported-locales.mjs';
let localeData = [].concat( let localeData = [].concat(
en, en,

View file

@ -22,8 +22,8 @@ module.exports = {
}, },
entry: { entry: {
l10n: './src/index.js', l10n: './src/index.js',
supportedLocales: './src/supported-locales.js', supportedLocales: './src/supported-locales.mjs',
localeData: './src/locale-data.js' localeData: './src/locale-data.mjs'
}, },
output: { output: {
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),