From 42bf3d81ad363fd40ea2240e379cbdd57500ea0e Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 17 Sep 2024 06:52:21 -0600 Subject: [PATCH] Update imports, see https://github.com/phetsims/chipper/issues/1459 --- js/grunt/tasks/build-images.ts | 4 ++-- js/grunt/tasks/build.ts | 10 ++++----- js/grunt/tasks/clean.ts | 4 ++-- js/grunt/tasks/commits-since.ts | 22 +++++++++---------- js/grunt/tasks/compare-phet-io-api.ts | 17 +++++++------- js/grunt/tasks/generate-a11y-view-html.ts | 2 +- js/grunt/tasks/generate-development-html.ts | 2 +- .../tasks/generate-development-strings.ts | 2 +- js/grunt/tasks/generate-phet-io-api.ts | 6 ++--- js/grunt/tasks/generate-test-html.ts | 2 +- js/grunt/tasks/generate-used-strings-file.ts | 2 +- js/grunt/tasks/lint-all.ts | 6 ++--- js/grunt/tasks/lint.ts | 6 ++--- js/grunt/tasks/modulify.ts | 4 ++-- js/grunt/tasks/output-js-all.ts | 4 ++++ js/grunt/tasks/output-js-project.ts | 3 ++- js/grunt/tasks/output-js.ts | 2 +- js/grunt/tasks/profile-file-size.ts | 2 +- js/grunt/tasks/published-README.ts | 2 +- js/grunt/tasks/report-media.ts | 2 +- js/grunt/tasks/sort-imports.ts | 6 ++--- js/grunt/tasks/test-grunt.ts | 2 +- js/grunt/tasks/unpublished-README.ts | 2 +- js/grunt/tasks/update-copyright-dates.ts | 2 +- js/grunt/tasks/update.ts | 10 ++++----- js/grunt/tasks/util/buildLocal.ts | 2 +- js/grunt/tasks/util/getBrands.ts | 9 ++++---- js/grunt/tasks/util/getOption.ts | 7 ++++-- js/grunt/tasks/util/getRepo.ts | 11 ++++++---- js/grunt/tasks/webpack-dev-server.ts | 4 ++-- package.json | 1 + tsconfig.json | 6 ++++- 32 files changed, 92 insertions(+), 74 deletions(-) diff --git a/js/grunt/tasks/build-images.ts b/js/grunt/tasks/build-images.ts index 3fcd5260c..b8bb69f64 100644 --- a/js/grunt/tasks/build-images.ts +++ b/js/grunt/tasks/build-images.ts @@ -5,8 +5,8 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); -const getRepo = require( './util/getRepo' ); +import * as grunt from 'grunt'; +import getRepo from './util/getRepo'; const jimp = require( 'jimp' ); const generateThumbnails = require( '../generateThumbnails' ); diff --git a/js/grunt/tasks/build.ts b/js/grunt/tasks/build.ts index 460873ff8..d9cfc5eb3 100644 --- a/js/grunt/tasks/build.ts +++ b/js/grunt/tasks/build.ts @@ -33,14 +33,14 @@ const path = require( 'path' ); const fs = require( 'fs' ); const getPhetLibs = require( '../getPhetLibs' ); const phetTimingLog = require( '../../../../perennial-alias/js/common/phetTimingLog' ); - -const grunt = require( 'grunt' ); -const getRepo = require( './util/getRepo' ); +import * as grunt from 'grunt'; +import getRepo from './util/getRepo'; const assert = require( 'assert' ); const Transpiler = require( '../../common/Transpiler' ); const getBrands = require( './util/getBrands' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; const buildLocal = require( './util/buildLocal' ); +import IntentionalAny from '../../../../phet-core/js/types/IntentionalAny.js'; const repo = getRepo(); @@ -51,7 +51,7 @@ const transpiler = new Transpiler( { silent: true } ); // Parse minification keys const minifyKeys = Object.keys( minify.MINIFY_DEFAULTS ); - const minifyOptions = {}; + const minifyOptions: IntentionalAny = {}; minifyKeys.forEach( minifyKey => { const option = getOption( `minify.${minifyKey}` ); if ( option === true || option === false ) { diff --git a/js/grunt/tasks/clean.ts b/js/grunt/tasks/clean.ts index 8df163c99..2a3c17de9 100644 --- a/js/grunt/tasks/clean.ts +++ b/js/grunt/tasks/clean.ts @@ -6,8 +6,8 @@ * @author Sam Reid (PhET Interactive Simulations) */ -const getRepo = require( './util/getRepo' ); -const grunt = require( 'grunt' ); +import getRepo from './util/getRepo'; +import * as grunt from 'grunt'; const repo = getRepo(); const buildDirectory = `../${repo}/build`; diff --git a/js/grunt/tasks/commits-since.ts b/js/grunt/tasks/commits-since.ts index 381b84459..c6f1a0c2a 100644 --- a/js/grunt/tasks/commits-since.ts +++ b/js/grunt/tasks/commits-since.ts @@ -1,25 +1,25 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); - /** * Shows commits since a specified date. Use --date= to specify the date. * * @author Sam Reid (PhET Interactive Simulations) */ - // TODO: https://github.com/phetsims/chipper/issues/1461 probably does not need to be here in grunt - // SR, AV, JB, MK, JG do not use it. We will check with @pixelzoom to see if it is OK to move to node. - // MK: But it is nice having a central registry + pattern for "things we run in sim/common repos" +// TODO: https://github.com/phetsims/chipper/issues/1461 probably does not need to be here in grunt +// SR, AV, JB, MK, JG do not use it. We will check with @pixelzoom to see if it is OK to move to node. +// MK: But it is nice having a central registry + pattern for "things we run in sim/common repos" +import getRepo from './util/getRepo'; -const repo = getRepo(); -const getOption = require( './util/getOption' ); +const commitsSince = require( '../commitsSince' ); +const assert = require( 'assert' ); +import getOption from './util/getOption'; +const repo = getRepo(); const dateString = getOption( 'date' ); assert( dateString, 'missing required option: --date={{DATE}}' ); -const commitsSince = require( '../commitsSince' ); -const assert = require( 'assert' ); - -await commitsSince( repo, dateString ); \ No newline at end of file +( async () => { + await commitsSince( repo, dateString ); +} )(); \ No newline at end of file diff --git a/js/grunt/tasks/compare-phet-io-api.ts b/js/grunt/tasks/compare-phet-io-api.ts index 4535e6dc3..e07efd39b 100644 --- a/js/grunt/tasks/compare-phet-io-api.ts +++ b/js/grunt/tasks/compare-phet-io-api.ts @@ -1,7 +1,5 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); - /** * * Compares the phet-io-api against the reference version(s) if this sim's package.json marks compareDesignedAPIChanges. @@ -15,22 +13,25 @@ const getRepo = require( './util/getRepo' ); * * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); +import * as grunt from 'grunt'; +import IntentionalAny from '../../../../phet-core/js/types/IntentionalAny.js'; +import getRepo from './util/getRepo'; + const getSimList = require( '../../common/getSimList' ); const generatePhetioMacroAPI = require( '../../phet-io/generatePhetioMacroAPI' ); const fs = require( 'fs' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; const repo = getRepo(); -const sims = getSimList().length === 0 ? [ repo ] : getSimList(); +const sims: string[] = getSimList().length === 0 ? [ repo ] : getSimList(); const temporary = getOption( 'temporary' ); -let proposedAPIs = null; +let proposedAPIs: Record | null = null; ( async () => { if ( temporary ) { proposedAPIs = {}; sims.forEach( sim => { - proposedAPIs[ sim ] = JSON.parse( fs.readFileSync( `../phet-io-sim-specific/repos/${repo}/${repo}-phet-io-api-temporary.json`, 'utf8' ) ); + proposedAPIs![ sim ] = JSON.parse( fs.readFileSync( `../phet-io-sim-specific/repos/${repo}/${repo}-phet-io-api-temporary.json`, 'utf8' ) ); } ); } else { @@ -46,7 +47,7 @@ let proposedAPIs = null; } // Don't add to options object if values are `undefined` (as _.extend will keep those entries and not mix in defaults - const options = {}; + const options: IntentionalAny = {}; if ( getOption( 'delta' ) ) { options.delta = getOption( 'delta' ); } diff --git a/js/grunt/tasks/generate-a11y-view-html.ts b/js/grunt/tasks/generate-a11y-view-html.ts index 577d945da..4f9f4fb28 100644 --- a/js/grunt/tasks/generate-a11y-view-html.ts +++ b/js/grunt/tasks/generate-a11y-view-html.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const generateA11yViewHTML = require( '../generateA11yViewHTML' ); /** diff --git a/js/grunt/tasks/generate-development-html.ts b/js/grunt/tasks/generate-development-html.ts index 66a69aacd..9e75e3867 100644 --- a/js/grunt/tasks/generate-development-html.ts +++ b/js/grunt/tasks/generate-development-html.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const generateDevelopmentHTML = require( '../generateDevelopmentHTML' ); /** diff --git a/js/grunt/tasks/generate-development-strings.ts b/js/grunt/tasks/generate-development-strings.ts index 7c7171fb2..d7089f667 100644 --- a/js/grunt/tasks/generate-development-strings.ts +++ b/js/grunt/tasks/generate-development-strings.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const generateDevelopmentStrings = require( '../generateDevelopmentStrings' ); const fs = require( 'fs' ); diff --git a/js/grunt/tasks/generate-phet-io-api.ts b/js/grunt/tasks/generate-phet-io-api.ts index a84284cc7..d1431f7ad 100644 --- a/js/grunt/tasks/generate-phet-io-api.ts +++ b/js/grunt/tasks/generate-phet-io-api.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * Output the PhET-iO API as JSON to phet-io-sim-specific/api. @@ -19,9 +19,9 @@ const formatPhetioAPI = require( '../../phet-io/formatPhetioAPI' ); const getSimList = require( '../../common/getSimList' ); const generatePhetioMacroAPI = require( '../../phet-io/generatePhetioMacroAPI' ); const fs = require( 'fs' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; -const sims = getSimList().length === 0 ? [ repo ] : getSimList(); +const sims: string[] = getSimList().length === 0 ? [ repo ] : getSimList(); // Ideally transpilation would be a no-op if the watch process is running. However, it can take 2+ seconds on // macOS to check all files, and sometimes much longer (50+ seconds) if the cache mechanism is failing. diff --git a/js/grunt/tasks/generate-test-html.ts b/js/grunt/tasks/generate-test-html.ts index 94643ffde..cb13e2ef5 100644 --- a/js/grunt/tasks/generate-test-html.ts +++ b/js/grunt/tasks/generate-test-html.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const generateTestHTML = require( '../generateTestHTML' ); /** diff --git a/js/grunt/tasks/generate-used-strings-file.ts b/js/grunt/tasks/generate-used-strings-file.ts index 0e9f7b854..614e3bd3e 100644 --- a/js/grunt/tasks/generate-used-strings-file.ts +++ b/js/grunt/tasks/generate-used-strings-file.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const getPhetLibs = require( '../getPhetLibs' ); const fs = require( 'fs' ); const webpackBuild = require( '../webpackBuild' ); diff --git a/js/grunt/tasks/lint-all.ts b/js/grunt/tasks/lint-all.ts index 776e5473f..c6941add1 100644 --- a/js/grunt/tasks/lint-all.ts +++ b/js/grunt/tasks/lint-all.ts @@ -1,9 +1,9 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const getBrands = require( './util/getBrands' ); const assert = require( 'assert' ); -const grunt = require( 'grunt' ); +import * as grunt from 'grunt'; const lint = require( '../lint' ); /** @@ -14,7 +14,7 @@ const lint = require( '../lint' ); const repo = getRepo(); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; const buildLocal = require( './util/buildLocal' ); // --disable-eslint-cache disables the cache, useful for developing rules diff --git a/js/grunt/tasks/lint.ts b/js/grunt/tasks/lint.ts index d77a7e02a..f7a59ef2a 100644 --- a/js/grunt/tasks/lint.ts +++ b/js/grunt/tasks/lint.ts @@ -9,10 +9,10 @@ * * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); -const getRepo = require( './util/getRepo' ); +import * as grunt from 'grunt'; +import getRepo from './util/getRepo'; const lint = require( '../lint' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; const repo = getRepo(); diff --git a/js/grunt/tasks/modulify.ts b/js/grunt/tasks/modulify.ts index 030393e07..c61d63211 100644 --- a/js/grunt/tasks/modulify.ts +++ b/js/grunt/tasks/modulify.ts @@ -1,8 +1,8 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const modulify = require( '../modulify' ); const generateDevelopmentStrings = require( '../generateDevelopmentStrings' ); -const fs = require( 'fs' ); +import * as fs from 'fs'; /** * Creates *.js modules for all images/strings/audio/etc in a repo diff --git a/js/grunt/tasks/output-js-all.ts b/js/grunt/tasks/output-js-all.ts index 84e013e65..469bad51d 100644 --- a/js/grunt/tasks/output-js-all.ts +++ b/js/grunt/tasks/output-js-all.ts @@ -5,6 +5,10 @@ * * @author Sam Reid (PhET Interactive Simulations) */ +// Import something to trigger imports mode. TODO https://github.com/phetsims/chipper/issues/1459 a better way? +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import IntentionalAny from '../../../../phet-core/js/types/IntentionalAny.js'; + const Transpiler = require( '../../common/Transpiler' ); const transpiler = new Transpiler( { silent: true } ); diff --git a/js/grunt/tasks/output-js-project.ts b/js/grunt/tasks/output-js-project.ts index 4da1dc342..6f8fe0497 100644 --- a/js/grunt/tasks/output-js-project.ts +++ b/js/grunt/tasks/output-js-project.ts @@ -6,7 +6,8 @@ * @author Sam Reid (PhET Interactive Simulations) */ const Transpiler = require( '../../common/Transpiler' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; + const transpiler = new Transpiler( { silent: true } ); const repos = getOption( 'repos' ); diff --git a/js/grunt/tasks/output-js.ts b/js/grunt/tasks/output-js.ts index 44afbab80..8b73ea70f 100644 --- a/js/grunt/tasks/output-js.ts +++ b/js/grunt/tasks/output-js.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * Outputs JS just for the specified repo diff --git a/js/grunt/tasks/profile-file-size.ts b/js/grunt/tasks/profile-file-size.ts index 7b3d5d929..053953c08 100644 --- a/js/grunt/tasks/profile-file-size.ts +++ b/js/grunt/tasks/profile-file-size.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * Profiles the file size of the built JS file for a given repo diff --git a/js/grunt/tasks/published-README.ts b/js/grunt/tasks/published-README.ts index 3c7d110db..aac020aba 100644 --- a/js/grunt/tasks/published-README.ts +++ b/js/grunt/tasks/published-README.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * Generates README.md file for a published simulation. diff --git a/js/grunt/tasks/report-media.ts b/js/grunt/tasks/report-media.ts index 6d3c599b2..27d225332 100644 --- a/js/grunt/tasks/report-media.ts +++ b/js/grunt/tasks/report-media.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * (project-wide) Report on license.json files throughout all working copies. diff --git a/js/grunt/tasks/sort-imports.ts b/js/grunt/tasks/sort-imports.ts index d09d3f7e7..caa999ef6 100644 --- a/js/grunt/tasks/sort-imports.ts +++ b/js/grunt/tasks/sort-imports.ts @@ -15,9 +15,9 @@ // MK: All opposed? // MK: is working on it. -const getRepo = require( './util/getRepo' ); -const grunt = require( 'grunt' ); -const getOption = require( './util/getOption' ); +import getRepo from './util/getRepo'; +import * as grunt from 'grunt'; +import getOption from './util/getOption'; const sortImports = require( '../sortImports' ); const repo = getRepo(); diff --git a/js/grunt/tasks/test-grunt.ts b/js/grunt/tasks/test-grunt.ts index 39fb168d5..ab8f9f46e 100644 --- a/js/grunt/tasks/test-grunt.ts +++ b/js/grunt/tasks/test-grunt.ts @@ -7,7 +7,7 @@ * @author Sam Reid (PhET Interactive Simulations) */ -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; // grunt test-grunt --brands=a,b,c --lint=false --noTSC const brands = getOption( 'brands' ); diff --git a/js/grunt/tasks/unpublished-README.ts b/js/grunt/tasks/unpublished-README.ts index 67b8e2b15..4c8b9bd02 100644 --- a/js/grunt/tasks/unpublished-README.ts +++ b/js/grunt/tasks/unpublished-README.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; /** * Generates README.md file for an unpublished simulation. diff --git a/js/grunt/tasks/update-copyright-dates.ts b/js/grunt/tasks/update-copyright-dates.ts index 1f1039ac0..841b1200c 100644 --- a/js/grunt/tasks/update-copyright-dates.ts +++ b/js/grunt/tasks/update-copyright-dates.ts @@ -1,6 +1,6 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const updateCopyrightDates = require( '../updateCopyrightDates' ); /** diff --git a/js/grunt/tasks/update.ts b/js/grunt/tasks/update.ts index 598c669f5..d62c9c731 100644 --- a/js/grunt/tasks/update.ts +++ b/js/grunt/tasks/update.ts @@ -1,7 +1,5 @@ // Copyright 2024, University of Colorado Boulder -const getRepo = require( './util/getRepo' ); - /** * Updates the normal automatically-generated files for this repository. Includes: * * runnables: generate-development-html and modulify @@ -13,13 +11,15 @@ const getRepo = require( './util/getRepo' ); * * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); +import * as grunt from 'grunt'; +import getRepo from './util/getRepo'; +import * as fs from 'fs'; + const repo = getRepo(); const packageObject = grunt.file.readJSON( `../${repo}/package.json` ); const generateREADME = require( '../generateREADME' ); -const fs = require( 'fs' ); const _ = require( 'lodash' ); // support repos that don't have a phet object @@ -65,7 +65,7 @@ else { grunt.file.write( 'package.json', JSON.stringify( packageObject, null, 2 ) ); } } - catch( e ) { + catch( e: IntentionalAny ) { if ( !e.message.includes( 'no such file or directory' ) ) { throw e; } diff --git a/js/grunt/tasks/util/buildLocal.ts b/js/grunt/tasks/util/buildLocal.ts index 01b88d3ca..b8e20facf 100644 --- a/js/grunt/tasks/util/buildLocal.ts +++ b/js/grunt/tasks/util/buildLocal.ts @@ -4,7 +4,7 @@ * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); +import * as grunt from 'grunt'; let buildLocal; try { diff --git a/js/grunt/tasks/util/getBrands.ts b/js/grunt/tasks/util/getBrands.ts index 70a8898ef..49ac66f12 100644 --- a/js/grunt/tasks/util/getBrands.ts +++ b/js/grunt/tasks/util/getBrands.ts @@ -4,9 +4,10 @@ * @author Sam Reid (PhET Interactive Simulations) */ const assert = require( 'assert' ); -const getOption = require( './getOption' ); +import IntentionalAny from '../../../../../phet-core/js/types/IntentionalAny.js'; +import getOption from './getOption'; -const getBrands = ( grunt, repo, buildLocal ) => { +const getBrands = ( grunt: IntentionalAny, repo: string, buildLocal: IntentionalAny ) => { // Determine what brands we want to build assert( !getOption( 'brand' ), 'Use --brands={{BRANDS}} instead of brand' ); @@ -14,7 +15,7 @@ const getBrands = ( grunt, repo, buildLocal ) => { const localPackageObject = grunt.file.readJSON( `../${repo}/package.json` ); const supportedBrands = localPackageObject.phet.supportedBrands || []; - let brands; + let brands: string[]; if ( getOption( 'brands' ) ) { if ( getOption( 'brands' ) === '*' ) { brands = supportedBrands; @@ -26,7 +27,7 @@ const getBrands = ( grunt, repo, buildLocal ) => { else if ( buildLocal.brands ) { // Extra check, see https://github.com/phetsims/chipper/issues/640 assert( Array.isArray( buildLocal.brands ), 'If brands exists in build-local.json, it should be an array' ); - brands = buildLocal.brands.filter( brand => supportedBrands.includes( brand ) ); + brands = buildLocal.brands.filter( ( brand: string ) => supportedBrands.includes( brand ) ); } else { brands = [ 'adapted-from-phet' ]; diff --git a/js/grunt/tasks/util/getOption.ts b/js/grunt/tasks/util/getOption.ts index f15080b64..76e14f1ab 100644 --- a/js/grunt/tasks/util/getOption.ts +++ b/js/grunt/tasks/util/getOption.ts @@ -7,9 +7,12 @@ // Use nopt to guarantee compatibility with grunt. See usage site: https://github.com/phetsims/chipper/issues/1459 // See usage in chipper/node_modules/grunt-cli/bin/grunt const nopt = require( 'nopt' ); +import IntentionalAny from '../../../../../phet-core/js/types/IntentionalAny.js'; const options = nopt( {}, {}, process.argv, 2 ); -module.exports = function( keyName ) { +function getOption( keyName: string ): IntentionalAny { return options[ keyName ]; -}; \ No newline at end of file +} + +export default getOption; \ No newline at end of file diff --git a/js/grunt/tasks/util/getRepo.ts b/js/grunt/tasks/util/getRepo.ts index d6da2af5e..b57720bc3 100644 --- a/js/grunt/tasks/util/getRepo.ts +++ b/js/grunt/tasks/util/getRepo.ts @@ -3,11 +3,12 @@ /** * @author Sam Reid (PhET Interactive Simulations) */ -const grunt = require( 'grunt' ); +import * as grunt from 'grunt'; + const assert = require( 'assert' ); -const getOption = require( './getOption' ); +import getOption from './getOption'; -module.exports = () => { +const getRepo = (): string => { const packageObject = grunt.file.readJSON( 'package.json' ); @@ -15,4 +16,6 @@ module.exports = () => { assert( typeof repo === 'string' && /^[a-z]+(-[a-z]+)*$/u.test( repo ), 'repo name should be composed of lower-case characters, optionally with dashes used as separators' ); return repo; -}; \ No newline at end of file +}; + +export default getRepo; \ No newline at end of file diff --git a/js/grunt/tasks/webpack-dev-server.ts b/js/grunt/tasks/webpack-dev-server.ts index d4d91e4ef..9fb34b42f 100644 --- a/js/grunt/tasks/webpack-dev-server.ts +++ b/js/grunt/tasks/webpack-dev-server.ts @@ -13,9 +13,9 @@ // TODO: https://github.com/phetsims/chipper/issues/1461 probably does not need to be here in grunt, or maybe just delete? // Dev meeting consensus: DELETE -const getRepo = require( './util/getRepo' ); +import getRepo from './util/getRepo'; const webpackDevServer = require( '../webpackDevServer' ); -const getOption = require( './util/getOption' ); +import getOption from './util/getOption'; const repo = getRepo(); diff --git a/package.json b/package.json index 96b34934e..76570cb5c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@babel/preset-react": "~7.18.6", "@babel/preset-typescript": "~7.21.4", "@stylistic/eslint-plugin": "~2.6.4", + "@types/grunt": "~0.4.31", "@types/jquery": "~3.5.13", "@types/lodash": "~4.14.172", "@types/p2": "~0.7.39", diff --git a/tsconfig.json b/tsconfig.json index adcfd8393..43a140589 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,5 +5,9 @@ "images/**/*", "mipmaps/**/*", "sounds/**/*" - ] + ], + "compilerOptions": { + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + } } \ No newline at end of file