Skip to content

Commit

Permalink
Remove "typescript": true, and isRepoTypeScript, see #1148
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 19, 2021
1 parent 758d446 commit 7631b5d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 40 deletions.
9 changes: 2 additions & 7 deletions js/grunt/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ module.exports = function( grunt ) {
const buildStandalone = require( './buildStandalone' );
const buildRunnable = require( './buildRunnable' );
const minify = require( './minify' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );
const tsc = require( './tsc' );
const reportTscResults = require( './reportTscResults' );
const isTypeScript = isRepoTypeScript( repo );
const path = require( 'path' );
const fs = require( 'fs' );

Expand All @@ -212,13 +210,10 @@ module.exports = function( grunt ) {

const repoPackageObject = grunt.file.readJSON( `../${repo}/package.json` );

// If the entry-point repo is marked for typescript, enable the typescript build chain.
// This begins with compiling the typescript into javascript, then the rest of the build process
// continues on the compiled javascript
if ( isTypeScript ) {
const results = await tsc( `../${repo}`, [ '--build' ] );
reportTscResults( results, grunt );
}
const results = await tsc( `../${repo}`, [ '--build' ] );
reportTscResults( results, grunt );

// standalone
if ( repoPackageObject.phet.buildStandalone ) {
Expand Down
7 changes: 2 additions & 5 deletions js/grunt/copySupplementalPhetioFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const minify = require( '../grunt/minify' );
const marked = require( 'marked' );
const tsc = require( './tsc' );
const reportTscResults = require( './reportTscResults' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );

// constants
const DEDICATED_REPO_WRAPPER_PREFIX = 'phet-io-wrapper-';
Expand Down Expand Up @@ -544,10 +543,8 @@ const handleStudio = async wrappersLocation => {

grunt.log.debug( 'building studio' );

if ( isRepoTypeScript( 'studio' ) ) {
const results = await tsc( '../studio', [ '--build' ] );
reportTscResults( results, grunt );
}
const results = await tsc( '../studio', [ '--build' ] );
reportTscResults( results, grunt );

fs.writeFileSync( `${wrappersLocation}studio/${STUDIO_BUILT_FILENAME}`, await buildStandalone( 'studio', {} ) );
};
4 changes: 1 addition & 3 deletions js/grunt/generateDevelopmentHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// modules
const _ = require( 'lodash' ); // eslint-disable-line require-statement-match
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );
const fixEOL = require( './fixEOL' );
const getPreloads = require( './getPreloads' );
const getStringRepos = require( './getStringRepos' );
Expand All @@ -27,15 +26,14 @@ const grunt = require( 'grunt' );
*/
module.exports = async function( repo, options ) {

const isTypeScript = isRepoTypeScript( repo );
const {
stylesheets = '',
bodystyle = ' style="background-color:black;"', // note the preceding ' ' which is essential
outputFile = `../${repo}/${repo}_en.html`,
bodystart = '',
addedPreloads = [], // none to add
stripPreloads = [], // none to add
mainFile = isTypeScript ? `../chipper/dist/${repo}/js/${repo}-main.js` : `js/${repo}-main.js`,
mainFile = `../chipper/dist/${repo}/js/${repo}-main.js`,
forSim = true // is this html used for a sim, or something else like tests.
} = options || {};

Expand Down
4 changes: 1 addition & 3 deletions js/grunt/generateTestHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@

const _ = require( 'lodash' ); // eslint-disable-line require-statement-match
const generateDevelopmentHTML = require( './generateDevelopmentHTML' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );

/**
* @param {string} repo
* @param {Object} [options]
* @returns {Promise.<undefined>}
*/
module.exports = async ( repo, options ) => {
const isTypeScript = isRepoTypeScript( repo );
await generateDevelopmentHTML( repo, _.merge( {

// Include QUnit CSS
Expand All @@ -38,7 +36,7 @@ module.exports = async ( repo, options ) => {
// Do not show the splash screen
stripPreloads: [ '../joist/js/splash.js' ],

mainFile: isTypeScript ? `../chipper/dist/${repo}/js/${repo}-tests.js` : `js/${repo}-tests.js`,
mainFile: `../chipper/dist/${repo}/js/${repo}-tests.js`,

// Specify to use test config
qualifier: 'test-',
Expand Down
5 changes: 1 addition & 4 deletions js/grunt/getStringMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const _ = require( 'lodash' ); // eslint-disable-line require-statement-match
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );
const fs = require( 'fs' );
const grunt = require( 'grunt' );
const localeInfo = require( '../data/localeInfo' ); // Locale information
Expand Down Expand Up @@ -148,8 +147,6 @@ module.exports = function( mainRepo, locales, phetLibs, usedModules ) {
stringMap[ locale ] = {};
} );

const isTypeScript = isRepoTypeScript( mainRepo );

// combine our strings into [locale][stringKey] map, using the fallback locale where necessary. In regards to nested
// strings, this data structure doesn't nest. Instead it gets nested string values, and then sets them with the
// flat key string like `"FRICTION/a11y.some.string.here": { value: 'My Some String' }`
Expand Down Expand Up @@ -192,7 +189,7 @@ module.exports = function( mainRepo, locales, phetLibs, usedModules ) {
stringAccesses = _.uniq( stringAccesses ).map( str => str.slice( prefix.length ) );

// The JS outputted by TS is minified and missing the whitespace
const depth = isTypeScript ? 2 : 3;
const depth = 2;

// Turn each string access into an array of parts, e.g. '.ResetAllButton.name' => [ 'ResetAllButton', 'name' ]
// or '[ \'A\' ].B[ \'C\' ]' => [ 'A', 'B', 'C' ]
Expand Down
16 changes: 6 additions & 10 deletions js/grunt/modulify.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const loadFileAsDataURI = require( '../common/loadFileAsDataURI' );
const os = require( 'os' );
const updateCopyrightForGeneratedFile = require( './updateCopyrightForGeneratedFile' );
const getCopyrightLine = require( './getCopyrightLine' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );

// disable lint in compiled files, because it increases the linting time
const HEADER = '/* eslint-disable */';
Expand Down Expand Up @@ -244,17 +243,16 @@ const modulifyFile = async ( abspath, rootdir, subdir, filename ) => {
*/
const createStringModule = async repo => {

const isTypeScript = isRepoTypeScript( repo );
const packageObject = grunt.file.readJSON( `../${repo}/package.json` );
const stringModuleFileJS = `../${repo}/js/${_.camelCase( repo )}Strings.js`;
const stringModuleFileTS = `../${repo}/js/${_.camelCase( repo )}Strings.ts`;
const namespace = _.camelCase( repo );

if ( isTypeScript && fs.existsSync( stringModuleFileJS ) ) {
if ( fs.existsSync( stringModuleFileJS ) ) {
console.log( 'Found JS string file in TS repo. It should be deleted manually. ' + stringModuleFileJS );
}

const stringModuleFile = isTypeScript ? stringModuleFileTS : stringModuleFileJS;
const stringModuleFile = stringModuleFileTS;

const copyrightLine = await getCopyrightLine( repo, `js/${_.camelCase( repo )}Strings.js` );
fs.writeFileSync( stringModuleFile, fixEOL(
Expand All @@ -263,15 +261,13 @@ const createStringModule = async repo => {
/**
* Auto-generated from modulify, DO NOT manually modify.
*/
${isTypeScript ? '/* eslint-disable */' : ''}
/* eslint-disable */
import getStringModule from '../../chipper/js/getStringModule.js';
import ${namespace} from './${namespace}.js';${
isTypeScript ? `
import ${namespace} from './${namespace}.js';
type StringsType = ${getStringTypes( repo )};` : ''
}
type StringsType = ${getStringTypes( repo )};
const ${namespace}Strings = getStringModule( '${packageObject.phet.requirejsNamespace}' )${isTypeScript ? ' as StringsType' : ''};
const ${namespace}Strings = getStringModule( '${packageObject.phet.requirejsNamespace}' ) as StringsType;
${namespace}.register( '${namespace}Strings', ${namespace}Strings );
Expand Down
6 changes: 1 addition & 5 deletions js/grunt/reportUnusedMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
* @author Jonathan Olson (PhET Interactive Simulations)
*/


// modules
const ChipperConstants = require( '../../../chipper/js/common/ChipperConstants' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );
const grunt = require( 'grunt' );

/**
Expand All @@ -27,8 +25,6 @@ const grunt = require( 'grunt' );
*/
module.exports = ( repo, usedModules ) => {

const isTypeScript = isRepoTypeScript( repo );

// on Windows, paths are reported with a backslash, normalize to forward slashes so this works everywhere
const normalizedUsedModules = usedModules.map( module => module.split( '\\' ).join( '/' ) );

Expand All @@ -45,7 +41,7 @@ module.exports = ( repo, usedModules ) => {
`${repo}/${mediaType}/${filename}`;

// If no licenseEntries were registered, or some were registered but not one corresponding to this file
if ( !normalizedUsedModules.includes( isTypeScript ? `chipper/dist/${module}` : module ) ) {
if ( !normalizedUsedModules.includes( `chipper/dist/${module}` ) ) {
grunt.log.warn( `Unused ${mediaType} module: ${module}` );
}
}
Expand Down
4 changes: 1 addition & 3 deletions js/grunt/webpackBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// modules
const ChipperConstants = require( '../common/ChipperConstants' );
const isRepoTypeScript = require( '../../../perennial-alias/js/common/isRepoTypeScript' );
const fs = require( 'fs' );
const path = require( 'path' );
const webpack = require( 'webpack' );
Expand Down Expand Up @@ -58,7 +57,6 @@ const getRelativeModules = modules => {
* @returns {Promise.<string>} - The combined JS output from the process
*/
module.exports = function( repo, brand ) {
const isTypeScript = isRepoTypeScript( repo );
return new Promise( ( resolve, reject ) => {
// Create plugins to ignore brands that we are not building at this time. Here "resource" is the module getting
// imported, and "context" is the directory that holds the module doing the importing. This is split up because
Expand Down Expand Up @@ -89,7 +87,7 @@ module.exports = function( repo, brand ) {

// Simulations or runnables will have a single entry point
entry: {
repo: isTypeScript ? `../chipper/dist/${repo}/js/${repo}-main.js` : `../${repo}/js/${repo}-main.js`
repo: `../chipper/dist/${repo}/js/${repo}-main.js`
},

// We output our builds to chipper/build/
Expand Down

0 comments on commit 7631b5d

Please sign in to comment.