Skip to content

Commit

Permalink
refactor!: stop using babel-node
Browse files Browse the repository at this point in the history
This should improve call stacks when debugging.

BREAKING CHANGE: Some files have been renamed from '.js' to '.mjs'
  • Loading branch information
cwillisf committed Oct 28, 2024
1 parent c7cb44a commit 44c4b97
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 41 deletions.
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ There are two situations in which we create manual PRs to update translations:

### Adding a language

* [ ] Edit `src/supported-locales.js`:
* [ ] Edit `src/supported-locales.mjs`:
* [ ] Add entry for the language in the `locales` const
* [ ] Check if language is right-to-left. If so:
* Add entry in `rtlLocales`

* [ ] 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:
* [ ] 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>'`
* [ ] Edit `.tx/config`:
* Add to the `lang_map` list. Format is `<Transifex ICU locale string>:<W3C HTML browser locale string>`
Expand All @@ -42,14 +42,14 @@ There are two situations in which we create manual PRs to update translations:
* [ ] Check if locale is in `react-intl`
* Look in [https://unpkg.com/react-intl/locale-data/](https://unpkg.com/react-intl/locale-data/)
* 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
* [ ] Edit `src/index.js`:
* In `localeData`, add entry for parent locale

* [ ] Update translations per the "Updating translations" section above
* [ ] Confirm that we see changes to:
* [ ] `src/supported-locales.js`
* [ ] `src/supported-locales.mjs`
* [ ] `src/index.js`
* [ ] `.tx/config` (if language needed a new locale)
* [ ] Multiple files like `editor/<resource>/<lang code>.json`
Expand Down
2 changes: 1 addition & 1 deletion lib/transifex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
},
"scripts": {
"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",
"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",
"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: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:articles": "./scripts/tx-pull-help-articles.js",
"pull:help:names": "./scripts/tx-pull-help-names.js",
"pull:interface": "babel-node scripts/tx-pull-editor scratch-editor interface ./editor/interface/",
"pull:paint": "babel-node scripts/tx-pull-editor scratch-editor paint-editor ./editor/paint-editor/",
"pull:www": "babel-node scripts/tx-pull-www ./www",
"push:help": "./scripts/tx-push-help.js",
"pull:interface": "node scripts/tx-pull-editor.mjs scratch-editor interface ./editor/interface/",
"pull:paint": "node scripts/tx-pull-editor.mjs scratch-editor paint-editor ./editor/paint-editor/",
"pull:www": "node scripts/tx-pull-www.mjs ./www",
"push:help": "./scripts/tx-push-help.mjs",
"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",
"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:extensions": "babel-node scripts/validate-translations ./editor/extensions/ && babel-node scripts/validate-extension-inputs",
"validate:interface": "babel-node scripts/validate-translations ./editor/interface/",
"validate:paint": "babel-node scripts/validate-translations ./editor/paint-editor/",
"validate:www": "babel-node scripts/validate-www ./www"
"validate:extensions": "node scripts/validate-translations.mjs ./editor/extensions/ && node scripts/validate-extension-inputs.mjs",
"validate:interface": "node scripts/validate-translations.mjs ./editor/interface/",
"validate:paint": "node scripts/validate-translations.mjs ./editor/paint-editor/",
"validate:www": "node scripts/validate-www.mjs ./www"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-data.js → scripts/build-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import * as fs from 'fs';
import * as path from 'path';
import {sync as mkdirpSync} from 'mkdirp';
import defaultsDeep from 'lodash.defaultsdeep';
import locales from '../src/supported-locales.js';
import locales from '../src/supported-locales.mjs';

const MSGS_DIR = './locales/';
mkdirpSync(MSGS_DIR);
Expand Down
6 changes: 3 additions & 3 deletions scripts/tx-pull-editor.js → scripts/tx-pull-editor.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand Down Expand Up @@ -29,8 +29,8 @@ if (!process.env.TX_TOKEN || args.length < 3) {
import fs from 'fs';
import path from 'path';
import {txPull} from '../lib/transifex.js';
import {validateTranslations} from '../lib/validate.js';
import locales, {localeMap} from '../src/supported-locales.js';
import {validateTranslations} from '../lib/validate.mjs';
import locales, {localeMap} from '../src/supported-locales.mjs';
import {batchMap} from '../lib/batch.js';

// Globals
Expand Down
4 changes: 2 additions & 2 deletions scripts/tx-pull-www.js → scripts/tx-pull-www.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand Down Expand Up @@ -31,7 +31,7 @@ import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
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';

// Globals
Expand Down
2 changes: 1 addition & 1 deletion scripts/tx-push-help.js → scripts/tx-push-help.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand All @@ -9,7 +9,7 @@ import fs from 'fs';
import path from 'path';
import async from 'async';
import assert from 'assert';
import locales from '../src/supported-locales.js';
import locales from '../src/supported-locales.mjs';

// Globals
const JSON_DIR = path.join(process.cwd(), '/editor/extensions');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

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

// Globals
const JSON_DIR = path.resolve(args[0]);
Expand Down
8 changes: 4 additions & 4 deletions scripts/validate-www.js → scripts/validate-www.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env babel-node
#!/usr/bin/env node

/**
* @fileoverview
Expand All @@ -8,7 +8,7 @@
const args = process.argv.slice(2);
const 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
`;
if (args.length < 1) {
Expand All @@ -19,8 +19,8 @@ import fs from 'fs';
import path from 'path';
import glob from 'glob';
import async from 'async';
import {validateTranslations} from '../lib/validate.js';
import locales from '../src/supported-locales.js';
import {validateTranslations} from '../lib/validate.mjs';
import locales from '../src/supported-locales.mjs';

// Globals
const WWW_DIR = path.resolve(args[0]);
Expand Down
3 changes: 0 additions & 3 deletions src/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
@@ -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};
2 changes: 1 addition & 1 deletion src/locale-data.js → src/locale-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import xh from './locale-data/xh';
import zh from './locale-data/zh';
import zu from './locale-data/zu';

import {customLocales} from './supported-locales.js';
import {customLocales} from './supported-locales.mjs';

let localeData = [].concat(
en,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = {
},
entry: {
l10n: './src/index.js',
supportedLocales: './src/supported-locales.js',
localeData: './src/locale-data.js'
supportedLocales: './src/supported-locales.mjs',
localeData: './src/locale-data.mjs'
},
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down

0 comments on commit 44c4b97

Please sign in to comment.