From d64b117e3e09785044ef4009b11aa72a1eeb182e Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 15 Oct 2024 07:51:37 -0600 Subject: [PATCH] Convert to TypeScript, see https://github.com/phetsims/chipper/issues/1465 --- js/grunt/{buildStandalone.js => buildStandalone.ts} | 12 +++++------- js/grunt/copySupplementalPhetioFiles.ts | 2 +- js/grunt/tasks/build.ts | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) rename js/grunt/{buildStandalone.js => buildStandalone.ts} (95%) diff --git a/js/grunt/buildStandalone.js b/js/grunt/buildStandalone.ts similarity index 95% rename from js/grunt/buildStandalone.js rename to js/grunt/buildStandalone.ts index 25ab9f6b6..e15aba48b 100644 --- a/js/grunt/buildStandalone.js +++ b/js/grunt/buildStandalone.ts @@ -6,8 +6,8 @@ * @author Jonathan Olson */ - import webpackBuild from './webpackBuild'; +import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.ts'; const assert = require( 'assert' ); const fs = require( 'fs' ); @@ -21,13 +21,11 @@ const getPhetLibs = require( './getPhetLibs' ); /** * Builds standalone JS deliverables (e.g. dot/kite/scenery) - * @public * - * @param {string} repo - * @param {Object} providedOptions - Passed directly to minify() - * @returns {Promise} + * @param repo + * @param providedOptions - Passed directly to minify() */ -module.exports = async function( repo, providedOptions ) { +export default async function( repo: string, providedOptions: IntentionalAny ): Promise { assert( typeof repo === 'string' ); assert( typeof providedOptions === 'object' ); @@ -136,4 +134,4 @@ module.exports = async function( repo, providedOptions ) { fullSource = minify( fullSource, options ); return fullSource; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/js/grunt/copySupplementalPhetioFiles.ts b/js/grunt/copySupplementalPhetioFiles.ts index 63125a6ef..a64693367 100644 --- a/js/grunt/copySupplementalPhetioFiles.ts +++ b/js/grunt/copySupplementalPhetioFiles.ts @@ -12,6 +12,7 @@ import * as fs from 'fs'; import * as _ from 'lodash'; import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js'; import webpackBuild from './webpackBuild.ts'; +import buildStandalone from './buildStandalone.ts'; const assert = require( 'assert' ); const archiver = require( 'archiver' ); @@ -21,7 +22,6 @@ const execute = require( '../../../perennial-alias/js/common/execute' ); const grunt = require( 'grunt' ); const generatePhetioMacroAPI = require( '../phet-io/generatePhetioMacroAPI' ); const formatPhetioAPI = require( '../phet-io/formatPhetioAPI' ); -const buildStandalone = require( '../grunt/buildStandalone' ); const minify = require( '../grunt/minify' ); const marked = require( 'marked' ); const tsc = require( './tsc' ); diff --git a/js/grunt/tasks/build.ts b/js/grunt/tasks/build.ts index f008140c1..79a4af43e 100644 --- a/js/grunt/tasks/build.ts +++ b/js/grunt/tasks/build.ts @@ -32,8 +32,7 @@ import reportTscResults from '../reportTscResults'; * * @author Sam Reid (PhET Interactive Simulations) */ - -const buildStandalone = require( '../buildStandalone' ); +import buildStandalone from '../buildStandalone'; const minify = require( '../minify' ); const tsc = require( '../tsc' ); @@ -104,7 +103,7 @@ export const build = ( async () => { minifyOptions.babelTranspile = false; minifyOptions.uglify = false; minifyOptions.isDebug = true; - fs.writeFileSync( `${parentDir}/${repo}.debug.js`, await buildStandalone( repo, minifyOptions, true ) ); + fs.writeFileSync( `${parentDir}/${repo}.debug.js`, await buildStandalone( repo, minifyOptions ) ); if ( repoPackageObject.phet.standaloneTranspiles ) { for ( const file of repoPackageObject.phet.standaloneTranspiles ) {