Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 6f11736

Browse files
Merge pull request #315 from google/esm
Convert the project to ECMAScript modules
2 parents 1ff4e61 + 2ed95d7 commit 6f11736

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2095
-2752
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,19 @@ jobs:
6161
run: yarn install --colors=always
6262
- name: Build jar
6363
# unset ANDROID_HOME to prevent bazel from trying to use the Android SDK
64-
run: unset ANDROID_HOME && ./build-scripts/build_compiler.js
64+
run: unset ANDROID_HOME && ./build-scripts/build-compiler.js
6565
- name: Tests
66-
run: node_modules/.bin/mocha --colors
66+
run: yarn test:root --color
6767
- name: Upload contrib folder
6868
uses: actions/upload-artifact@v4
6969
with:
7070
name: Contrib folder
7171
path: compiler/contrib
72+
- name: Upload externs folder
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: Externs folder
76+
path: compiler/externs
7277
- name: Upload compiler jar
7378
uses: actions/upload-artifact@v4
7479
with:
@@ -120,6 +125,11 @@ jobs:
120125
with:
121126
name: Contrib folder
122127
path: packages/google-closure-compiler/contrib
128+
- name: Download externs folder
129+
uses: actions/download-artifact@v4
130+
with:
131+
name: Externs folder
132+
path: packages/google-closure-compiler/externs
123133
- name: Get yarn cache directory path
124134
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
125135
- name: Cache yarn
@@ -139,7 +149,7 @@ jobs:
139149
yarn run build
140150
upx compiler
141151
- name: Tests
142-
run: yarn workspaces run test --colors
152+
run: yarn workspaces run test --color
143153
- name: Upload artifacts
144154
uses: actions/upload-artifact@v4
145155
with:
@@ -191,6 +201,11 @@ jobs:
191201
with:
192202
name: Contrib folder
193203
path: packages/google-closure-compiler/contrib
204+
- name: Download externs folder
205+
uses: actions/download-artifact@v4
206+
with:
207+
name: Externs folder
208+
path: packages/google-closure-compiler/externs
194209
- name: Get yarn cache directory path
195210
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
196211
- name: Cache yarn
@@ -210,7 +225,7 @@ jobs:
210225
yarn run build
211226
upx compiler
212227
- name: Tests
213-
run: yarn workspaces run test --colors
228+
run: yarn workspaces run test --color
214229
- name: Upload artifacts
215230
uses: actions/upload-artifact@v4
216231
with:
@@ -257,6 +272,11 @@ jobs:
257272
with:
258273
name: Contrib folder
259274
path: packages/google-closure-compiler/contrib
275+
- name: Download externs folder
276+
uses: actions/download-artifact@v4
277+
with:
278+
name: Externs folder
279+
path: packages/google-closure-compiler/externs
260280
- name: Get yarn cache directory path
261281
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_ENV
262282
- name: Cache yarn
@@ -276,7 +296,7 @@ jobs:
276296
yarn run build
277297
# upx compiler
278298
- name: Tests
279-
run: yarn workspaces run test --colors
299+
run: yarn workspaces run test --color
280300
- name: Upload artifacts
281301
uses: actions/upload-artifact@v4
282302
with:
@@ -320,6 +340,11 @@ jobs:
320340
with:
321341
name: Contrib folder
322342
path: packages/google-closure-compiler/contrib
343+
- name: Download externs folder
344+
uses: actions/download-artifact@v4
345+
with:
346+
name: Externs folder
347+
path: packages/google-closure-compiler/externs
323348
- name: Get yarn cache directory path
324349
# See https://stackoverflow.com/a/66737579/1211524
325350
run: echo "yarn_cache_dir=$(yarn cache dir)" >> $env:GITHUB_ENV
@@ -342,7 +367,7 @@ jobs:
342367
shell: cmd
343368
run: |
344369
echo "Running Tests"
345-
yarn workspaces run test --colors
370+
yarn workspaces run test --color
346371
- name: Upload artifacts
347372
uses: actions/upload-artifact@v4
348373
with:
@@ -401,6 +426,11 @@ jobs:
401426
with:
402427
name: Contrib folder
403428
path: packages/google-closure-compiler/contrib
429+
- name: Download externs folder
430+
uses: actions/download-artifact@v4
431+
with:
432+
name: Externs folder
433+
path: packages/google-closure-compiler/externs
404434
- name: Mark binaries executable
405435
run: |
406436
chmod 755 packages/google-closure-compiler-linux/compiler

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install packages
5050
run: yarn install --colors=always
5151
- name: Build jar
52-
run: ./build-scripts/build_compiler.js
52+
run: ./build-scripts/build-compiler.js
5353
- name: Create release commit and tag
5454
run: |
5555
git config --global user.email "[email protected]"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ npm-debug.log
33
yarn-error.log
44
/lerna-debug.log
55
/packages/google-closure-compiler/contrib/
6+
/packages/google-closure-compiler/externs/
67
/packages/google-closure-compiler-java/compiler.jar
78
/packages/google-closure-compiler-linux/compiler.jar
89
/packages/google-closure-compiler-linux/compiler

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ Bare bones distributions intended for developers who want to author against a sp
2121

2222
- Java build: [google-closure-compiler-java](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-java)
2323
- Native Linux build: [google-closure-compiler-linux](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-linux)
24-
- Native OSX build: [google-closure-compiler-osx](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-osx)
24+
- Native Linux (arm64) build: [google-closure-compiler-linux-arm64](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-linux-arm64)
25+
- Native MacOS build: [google-closure-compiler-macos](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-macos)
2526
- Native Windows build: [google-closure-compiler-windows](https://github.com/google/closure-compiler-npm/tree/master/packages/google-closure-compiler-windows)
2627

2728
## License

build-scripts/add-os-restrictions.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
'use strict';
1817
/**
1918
* @fileoverview
2019
*
@@ -23,8 +22,11 @@
2322
* Also set correct architectures. In order to execute `yarn install` in the main package, the current architecture
2423
*/
2524

26-
const fs = require('fs');
27-
const path = require('path');
25+
import fs from 'node:fs';
26+
import path from 'node:path';
27+
import {fileURLToPath, URL} from 'node:url';
28+
29+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
2830

2931
// Maps of the os marketing name to the platform name used in package.json os restriction fields
3032
const osRestrictions = new Map([

build-scripts/build_compiler.js renamed to build-scripts/build-compiler.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@
2929
* commit. This is for regular integration testing of the compiler with the various tests in this repo's packages.
3030
* In this case the compiler will be built as a SNAPSHOT.
3131
*/
32-
"use strict";
32+
import fs from 'node:fs';
33+
import path from 'node:path';
34+
import {fileURLToPath, URL} from 'node:url';
35+
import ncp from 'ncp';
36+
import semver from 'semver';
37+
import runCommand from './run-command.js';
3338

34-
const ncp = require("ncp");
35-
const runCommand = require("./run-command");
36-
const packageInfo = require("../package.json");
37-
const semver = require("semver");
39+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
40+
const packageInfo = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf-8'));
3841

3942
/**
4043
* The compiler version that will be built.
@@ -44,7 +47,7 @@ const semver = require("semver");
4447
*
4548
* @type {string}
4649
*/
47-
const compilerVersion = process.env.COMPILER_NIGHTLY == 'true'
50+
const compilerVersion = process.env.COMPILER_NIGHTLY === 'true'
4851
? 'SNAPSHOT-1.0'
4952
: `v${semver.major(packageInfo.version)}`;
5053

build-scripts/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22
# Run the build commands and fail the script if any of them failed
3-
./build-scripts/build_compiler.js "$@" && yarn workspaces run build "$@"
3+
./build-scripts/build-compiler.js "$@" && yarn workspaces run build "$@"

build-scripts/colors.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

build-scripts/ensure-file-exists.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
const fs = require('fs');
19-
const colors = require('./colors');
18+
import fs from 'node:fs';
19+
import chalk from 'chalk';
2020

2121
if (!fs.existsSync(process.argv[2])) {
22-
process.stderr.write(`${colors.RED}${process.argv[2]} file is missing${colors.RESET}\n`);
22+
process.stderr.write(chalk.red(`${process.argv[2]} file is missing\n`));
2323
process.exitCode = 1;
2424
}

build-scripts/graal.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
'use strict';
1817
/**
1918
* @fileoverview
2019
*
2120
* Build the graal native compiler image for the current OS.
2221
* Intended to be run with a working directory of the intended package.
2322
*/
2423

25-
const path = require('path');
26-
const runCommand = require('./run-command');
24+
import path from 'node:path';
25+
import {fileURLToPath, URL} from 'node:url';
26+
import runCommand from './run-command.js';
27+
28+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
2729

2830
// This script should catch and handle all rejected promises.
2931
// If it ever fails to do so, report that and exit immediately.

0 commit comments

Comments
 (0)