-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run Grunt tasks in separate processes #1459
Comments
Patch to go into npx tsx: Subject: [PATCH] Revert multi-modal transpilation output, see https://github.com/phetsims/chipper/issues/1459
---
Index: js/grunt/typescript-test.ts
===================================================================
diff --git a/js/grunt/typescript-test.ts b/js/grunt/typescript-test.ts
deleted file mode 100644
--- a/js/grunt/typescript-test.ts (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ /dev/null (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
@@ -1,18 +0,0 @@
-// Copyright 2024, University of Colorado Boulder
-
-/**
- * TODO: delete as part of https://github.com/phetsims/chipper/issues/1437
- * @author Michael Kauzmann (PhET Interactive Simulations)
- * @author Sam Reid (PhET Interactive Simulations)
- */
-
-module.exports = function typescriptTest() {
-
- const myTestNumber = 9;
-
- function myPrintFunc( x: number ): void {
- console.log( x );
- }
-
- myPrintFunc( myTestNumber );
-};
\ No newline at end of file
Index: js/grunt/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/.eslintrc.js b/js/grunt/.eslintrc.js
--- a/js/grunt/.eslintrc.js (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/js/grunt/.eslintrc.js (date 1726152280519)
@@ -4,5 +4,31 @@
module.exports = {
// Use all of the default rules from eslint file for node code.
- extends: '../../../chipper/eslint/chipper_eslintrc.js'
+ extends: process.cwd().substring( 0, process.cwd().lastIndexOf( 'chipper' ) + 'chipper'.length ) + '/eslint/chipper_eslintrc.js',
+
+ parserOptions: {
+ sourceType: 'module'
+ },
+
+ overrides: [ {
+ files: [ '**/*.ts' ],
+
+ parserOptions: {
+
+ // Provide a tsconfig so that we can use rules that require type information.
+ // NOTE: Providing this slows down eslint substantially, see https://github.com/phetsims/chipper/issues/1114#issuecomment-1065927717
+
+ // IntelliJ runs this from chipper/js/grunt so the path is different than when running from chipper/, so we must normalize
+ // to support both IDE and command line
+ // for debugging here, you can put variables into the project then navigate to a file using this (like a *.ts file)
+ // and see the output in the bad path, or you can write to the file system.
+ project: [ process.cwd().substring( 0, process.cwd().lastIndexOf( 'chipper' ) + 'chipper'.length ) + '/tsconfig/all/tsconfig.json' ]
+ },
+
+ // disable rules @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
+ rules: {
+ '@typescript-eslint/no-require-imports': 'off',
+ '@typescript-eslint/no-var-requires': 'off'
+ }
+ } ]
};
\ No newline at end of file
Index: tsconfig/all/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig/all/tsconfig.json b/tsconfig/all/tsconfig.json
--- a/tsconfig/all/tsconfig.json (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/tsconfig/all/tsconfig.json (date 1726151891950)
@@ -32,7 +32,7 @@
"../../../center-and-variability/images/**/*",
"../../../chipper/phet-types.d.ts",
"../../../chipper/phet-types-module.d.ts",
- "../../../chipper/js/grunt/typescript-test.ts",
+ "../../../chipper/js/grunt/**/*",
"../../../circuit-construction-kit-ac/js/**/*",
"../../../circuit-construction-kit-ac-virtual-lab/js/**/*",
"../../../circuit-construction-kit-common/js/**/*",
Index: js/grunt/tasks/update.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/update.js b/js/grunt/tasks/update.js
--- a/js/grunt/tasks/update.js (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/js/grunt/tasks/update.js (date 1726152358767)
@@ -25,6 +25,7 @@
// modulify is graceful if there are no files that need modulifying.
// TODO: This used to be grunt.task.run, is plain require correct here? https://github.com/phetsims/chipper/issues/1459
+ // TODO: Does this process the command line args correctly? see https://github.com/phetsims/chipper/issues/1459
require( './modulify' );
// update README.md only for simulations
Index: js/grunt/tasks/build.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/build.js b/js/grunt/tasks/build.ts
rename from js/grunt/tasks/build.js
rename to js/grunt/tasks/build.ts
--- a/js/grunt/tasks/build.js (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/js/grunt/tasks/build.ts (date 1726152524910)
@@ -16,6 +16,8 @@
const grunt = require( 'grunt' );
const getRepo = require( './getRepo' );
+
+// @ts-expect-error - overlaps with global assert in phet-types.d.ts TODO https://github.com/phetsims/chipper/issues/1459
const assert = require( 'assert' );
const Transpiler = require( '../../common/Transpiler' );
const getBrands = require( './getBrands' );
@@ -29,12 +31,12 @@
const transpiler = new Transpiler( { silent: true } );
-( async () => {
+( async () => { /* eslint-disable-line @typescript-eslint/no-floating-promises */ // TODO: https://github.com/phetsims/chipper/issues/1459 ???
await phetTimingLog.startAsync( 'grunt-build', async () => {
// Parse minification keys
const minifyKeys = Object.keys( minify.MINIFY_DEFAULTS );
- const minifyOptions = {};
+ const minifyOptions: Record<string, unknown> = {};
minifyKeys.forEach( minifyKey => {
const option = grunt.option( `minify.${minifyKey}` );
if ( option === true || option === false ) {
@@ -101,7 +103,7 @@
else {
const localPackageObject = grunt.file.readJSON( `../${repo}/package.json` );
- assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` );
+ assert && assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` );
grunt.log.writeln( `Building runnable repository (${repo}, brands: ${brands.join( ', ' )})` );
// Other options
Index: js/grunt/Gruntfile.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js
--- a/js/grunt/Gruntfile.js (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/js/grunt/Gruntfile.js (date 1726151489505)
@@ -41,13 +41,22 @@
// TODO switch to npx tsx, see https://github.com/phetsims/chipper/issues/1459 via npx ../chipper/node_modules/tsx
// TODO: test on windows, see https://github.com/phetsims/chipper/issues/1459
- const command = 'node';
+ const command = 'npx';
return () => {
const done = grunt.task.current.async();
try {
- const child = spawn( command, [ `../chipper/js/grunt/tasks/${taskFilename}`, ...process.argv.slice( 2 ) ], { stdio: [ 'inherit', 'pipe', 'pipe' ] } );
+ const child = spawn( command, [
+
+ // so we don't have to install tsx globally or in every sim repo
+ '../chipper/node_modules/tsx',
+
+ `../chipper/js/grunt/tasks/${taskFilename}`,
+ ...process.argv.slice( 2 )
+ ], {
+ stdio: [ 'inherit', 'pipe', 'pipe' ]
+ } );
child.stdout.on( 'data', data => process.stdout.write( data.toString() ) );
child.stderr.on( 'data', data => process.stderr.write( data.toString() ) );
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision 00b31dedbb416ba07f5291c27f63c904ccf929b2)
+++ b/package.json (date 1726146952884)
@@ -58,6 +58,7 @@
"taffydb": "~2.7.3",
"terser": "~4.6.4",
"ts-morph": "^21.0.1",
+ "tsx": "^4.19.1",
"typescript": "~5.5.4",
"webpack": "~5.76.3",
"webpack-cli": "~5.0.0", |
Current jab script: function jab() {
# The base directory where all your task scripts are stored
base_dir="../chipper/js/grunt/tasks"
# Check if the first argument is missing or starts with a hyphen (indicating options)
if [[ -z "$1" || "$1" =~ ^- ]]; then
task="build"
else
task="$1"
shift
fi
# Construct the paths to the script files (both .ts and .js)
ts_script_file="$base_dir/${task}.ts"
js_script_file="$base_dir/${task}.js"
# Check if the .ts script file exists first
if [[ -f "$ts_script_file" ]]; then
# Execute the command with the remaining arguments using the TypeScript file
../chipper/node_modules/.bin/tsx "$ts_script_file" "$@"
# If the .ts file doesn't exist, check for the .js file
elif [[ -f "$js_script_file" ]]; then
# Execute the command with the remaining arguments using the JavaScript file
../chipper/node_modules/.bin/tsx "$js_script_file" "$@"
else
# If neither file is found, display an error message
echo "Unknown command or script file not found: $task"
fi
} |
Update patch: Subject: [PATCH] Revert multi-modal transpilation output, see https://github.com/phetsims/chipper/issues/1459
---
Index: js/grunt/typescript-test.ts
===================================================================
diff --git a/js/grunt/typescript-test.ts b/js/grunt/typescript-test.ts
deleted file mode 100644
--- a/js/grunt/typescript-test.ts (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ /dev/null (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
@@ -1,18 +0,0 @@
-// Copyright 2024, University of Colorado Boulder
-
-/**
- * TODO: delete as part of https://github.com/phetsims/chipper/issues/1437
- * @author Michael Kauzmann (PhET Interactive Simulations)
- * @author Sam Reid (PhET Interactive Simulations)
- */
-
-module.exports = function typescriptTest() {
-
- const myTestNumber = 9;
-
- function myPrintFunc( x: number ): void {
- console.log( x );
- }
-
- myPrintFunc( myTestNumber );
-};
\ No newline at end of file
Index: js/grunt/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/.eslintrc.js b/js/grunt/.eslintrc.js
--- a/js/grunt/.eslintrc.js (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/js/grunt/.eslintrc.js (date 1726170610759)
@@ -4,5 +4,31 @@
module.exports = {
// Use all of the default rules from eslint file for node code.
- extends: '../../../chipper/eslint/chipper_eslintrc.js'
+ extends: process.cwd().substring( 0, process.cwd().lastIndexOf( 'chipper' ) + 'chipper'.length ) + '/eslint/chipper_eslintrc.js',
+
+ parserOptions: {
+ sourceType: 'module'
+ },
+
+ overrides: [ {
+ files: [ '**/*.ts' ],
+
+ parserOptions: {
+
+ // Provide a tsconfig so that we can use rules that require type information.
+ // NOTE: Providing this slows down eslint substantially, see https://github.com/phetsims/chipper/issues/1114#issuecomment-1065927717
+
+ // IntelliJ runs this from chipper/js/grunt so the path is different than when running from chipper/, so we must normalize
+ // to support both IDE and command line
+ // for debugging here, you can put variables into the project then navigate to a file using this (like a *.ts file)
+ // and see the output in the bad path, or you can write to the file system.
+ project: [ process.cwd().substring( 0, process.cwd().lastIndexOf( 'chipper' ) + 'chipper'.length ) + '/tsconfig/all/tsconfig.json' ]
+ },
+
+ // disable rules @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires
+ rules: {
+ '@typescript-eslint/no-require-imports': 'off',
+ '@typescript-eslint/no-var-requires': 'off'
+ }
+ } ]
};
\ No newline at end of file
Index: tsconfig/all/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig/all/tsconfig.json b/tsconfig/all/tsconfig.json
--- a/tsconfig/all/tsconfig.json (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/tsconfig/all/tsconfig.json (date 1726170610786)
@@ -32,7 +32,7 @@
"../../../center-and-variability/images/**/*",
"../../../chipper/phet-types.d.ts",
"../../../chipper/phet-types-module.d.ts",
- "../../../chipper/js/grunt/typescript-test.ts",
+ "../../../chipper/js/grunt/**/*",
"../../../circuit-construction-kit-ac/js/**/*",
"../../../circuit-construction-kit-ac-virtual-lab/js/**/*",
"../../../circuit-construction-kit-common/js/**/*",
Index: js/grunt/tasks/update.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/update.js b/js/grunt/tasks/update.js
--- a/js/grunt/tasks/update.js (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/js/grunt/tasks/update.js (date 1726170610751)
@@ -25,6 +25,7 @@
// modulify is graceful if there are no files that need modulifying.
// TODO: This used to be grunt.task.run, is plain require correct here? https://github.com/phetsims/chipper/issues/1459
+ // TODO: Does this process the command line args correctly? see https://github.com/phetsims/chipper/issues/1459
require( './modulify' );
// update README.md only for simulations
Index: tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig.json b/tsconfig.json
--- a/tsconfig.json (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/tsconfig.json (date 1726171296778)
@@ -5,5 +5,8 @@
"images/**/*",
"mipmaps/**/*",
"sounds/**/*"
- ]
+ ],
+ "compilerOptions": {
+ "allowSyntheticDefaultImports": true
+ }
}
\ No newline at end of file
Index: js/grunt/Gruntfile.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/Gruntfile.js b/js/grunt/Gruntfile.js
--- a/js/grunt/Gruntfile.js (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/js/grunt/Gruntfile.js (date 1726171111960)
@@ -41,13 +41,22 @@
// TODO switch to npx tsx, see https://github.com/phetsims/chipper/issues/1459 via npx ../chipper/node_modules/tsx
// TODO: test on windows, see https://github.com/phetsims/chipper/issues/1459
- const command = 'node';
+ const command = '../chipper/node_modules/.bin/tsx';
return () => {
const done = grunt.task.current.async();
try {
- const child = spawn( command, [ `../chipper/js/grunt/tasks/${taskFilename}`, ...process.argv.slice( 2 ) ], { stdio: [ 'inherit', 'pipe', 'pipe' ] } );
+ const child = spawn( command, [
+
+ // so we don't have to install tsx globally or in every sim repo
+ // '../chipper/node_modules/tsx',
+
+ `../chipper/js/grunt/tasks/${taskFilename}`,
+ ...process.argv.slice( 2 )
+ ], {
+ stdio: [ 'inherit', 'pipe', 'pipe' ]
+ } );
child.stdout.on( 'data', data => process.stdout.write( data.toString() ) );
child.stderr.on( 'data', data => process.stderr.write( data.toString() ) );
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/package.json (date 1726170610796)
@@ -58,6 +58,7 @@
"taffydb": "~2.7.3",
"terser": "~4.6.4",
"ts-morph": "^21.0.1",
+ "tsx": "^4.19.1",
"typescript": "~5.5.4",
"webpack": "~5.76.3",
"webpack-cli": "~5.0.0",
Index: js/grunt/tasks/parseGruntOptions.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/parseGruntOptions.js b/js/grunt/tasks/parseGruntOptions.js
--- a/js/grunt/tasks/parseGruntOptions.js (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/js/grunt/tasks/parseGruntOptions.js (date 1726171440639)
@@ -6,7 +6,7 @@
// TODO: Replace with nopt 4.0.1 to guarantee compatibility with grunt. See usage site: https://github.com/phetsims/chipper/issues/1459
// /Users/samreid/phet/root/chipper/node_modules/grunt-cli/bin/grunt
-module.exports = function( grunt ) {
+const myFunc = function( grunt ) {
function parseArgs( argv ) {
const args = {};
argv.forEach( ( arg, index ) => {
@@ -33,4 +33,8 @@
const parsedArgs = parseArgs( process.argv.slice( 2 ) );
return parsedArgs;
-};
\ No newline at end of file
+};
+
+myFunc.tester = 'hello';
+
+module.exports = myFunc;
\ No newline at end of file
Index: js/grunt/tasks/build.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/build.js b/js/grunt/tasks/build.ts
rename from js/grunt/tasks/build.js
rename to js/grunt/tasks/build.ts
--- a/js/grunt/tasks/build.js (revision 8c920866f087ccc42cd1916f2eadf61e699cae95)
+++ b/js/grunt/tasks/build.ts (date 1726171440649)
@@ -16,25 +16,36 @@
const grunt = require( 'grunt' );
const getRepo = require( './getRepo' );
+
+// @ts-expect-error - overlaps with global assert in phet-types.d.ts TODO https://github.com/phetsims/chipper/issues/1459
const assert = require( 'assert' );
const Transpiler = require( '../../common/Transpiler' );
const getBrands = require( './getBrands' );
-const parseGruntOptions = require( './parseGruntOptions' );
+import parseGruntOptions from './parseGruntOptions';
+
+console.log( parseGruntOptions );
+
+parseGruntOptions.tester;
+parseGruntOptions.minify;
+// parseGruntOptions.hello;
+// parseGruntOptions();
+
const repo = getRepo();
+
// Initialize Grunt options with parsed arguments
// Call this before getBrands
grunt.option.init( parseGruntOptions() );
const transpiler = new Transpiler( { silent: true } );
-( async () => {
+( async () => { /* eslint-disable-line @typescript-eslint/no-floating-promises */ // TODO: https://github.com/phetsims/chipper/issues/1459 ???
await phetTimingLog.startAsync( 'grunt-build', async () => {
// Parse minification keys
const minifyKeys = Object.keys( minify.MINIFY_DEFAULTS );
- const minifyOptions = {};
+ const minifyOptions: Record<string, unknown> = {};
minifyKeys.forEach( minifyKey => {
const option = grunt.option( `minify.${minifyKey}` );
if ( option === true || option === false ) {
@@ -101,7 +112,7 @@
else {
const localPackageObject = grunt.file.readJSON( `../${repo}/package.json` );
- assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` );
+ assert && assert( localPackageObject.phet.runnable, `${repo} does not appear to be runnable` );
grunt.log.writeln( `Building runnable repository (${repo}, brands: ${brands.join( ', ' )})` );
// Other options |
Patch for tsconfig and next steps: Subject: [PATCH] Fix module resolution and import jimp, see https://github.com/phetsims/chipper/issues/1459
---
Index: js/getStringModule.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/getStringModule.ts b/js/getStringModule.ts
--- a/js/getStringModule.ts (revision ce419be8db96fdfa2883db184e96eba02b056900)
+++ b/js/getStringModule.ts (date 1726592587961)
@@ -41,6 +41,21 @@
} );
};
+process.env;
+process.blarg;
+
+document.hello;
+window.hello;
+global.hello;
+
+global.process;
+global.hello;
+
+window.location;
+
+const myDiv = document.createElement( 'div' );
+console.log( myDiv );
+
const stringKeyToTandemName = ( key: string ) => {
return key.replace( /(?:[-_\s]\w)/g, word => word[ 1 ].toUpperCase() );
};
Index: tsconfig-node.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig-node.json b/tsconfig-node.json
new file mode 100644
--- /dev/null (date 1726592503627)
+++ b/tsconfig-node.json (date 1726592503627)
@@ -0,0 +1,31 @@
+{
+ "extends": "./tsconfig-supercore.json",
+ "compilerOptions": {
+ // Treat files as modules even if it doesn't use import/export
+ "moduleDetection": "force",
+ // Ignore module structure
+ "module": "NodeNext",
+ // Allow JSON modules to be imported
+ "resolveJsonModule": true,
+ // Allow JS files to be imported from TS and vice versa
+ "allowJs": true,
+ // Use correct ESM import behavior
+ "esModuleInterop": true,
+ // Disallow features that require cross-file awareness
+ "isolatedModules": true,
+ "strict": true,
+ "moduleResolution": "NodeNext",
+ "target": "ESNext",
+ "lib": [
+ "ESNext"
+ ]
+ }
+}
+
+/*
+,
+"compilerOptions": {
+"esModuleInterop": true,
+"allowSyntheticDefaultImports": true,
+"moduleResolution": "node"
+}*/
Index: js/grunt/tasks/update.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/update.ts b/js/grunt/tasks/update.ts
--- a/js/grunt/tasks/update.ts (revision ce419be8db96fdfa2883db184e96eba02b056900)
+++ b/js/grunt/tasks/update.ts (date 1726592424359)
@@ -14,6 +14,7 @@
import * as grunt from 'grunt';
import getRepo from './util/getRepo';
import * as fs from 'fs';
+import IntentionalAny from '../../../../phet-core/js/types/IntentionalAny.js';
const repo = getRepo();
Index: tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig.json b/tsconfig.json
--- a/tsconfig.json (revision ce419be8db96fdfa2883db184e96eba02b056900)
+++ b/tsconfig.json (date 1726593261728)
@@ -6,9 +6,10 @@
"mipmaps/**/*",
"sounds/**/*"
],
- "compilerOptions": {
- "esModuleInterop": true,
- "allowSyntheticDefaultImports": true,
- "moduleResolution": "node"
- }
+ "files": [
+ "js/Gruntfile.ts"
+ ],
+ "exclude": [
+ "js/grunt/**/*"
+ ]
}
\ No newline at end of file
Index: js/grunt/tasks/clean.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tasks/clean.ts b/js/grunt/tasks/clean.ts
--- a/js/grunt/tasks/clean.ts (revision ce419be8db96fdfa2883db184e96eba02b056900)
+++ b/js/grunt/tasks/clean.ts (date 1726592587969)
@@ -6,8 +6,8 @@
* @author Sam Reid (PhET Interactive Simulations)
*/
-import getRepo from './util/getRepo';
import * as grunt from 'grunt';
+import getRepo from './util/getRepo';
const repo = getRepo();
const buildDirectory = `../${repo}/build`;
@@ -16,4 +16,19 @@
if ( grunt.file.exists( buildDirectory ) ) {
grunt.file.delete( buildDirectory );
}
-grunt.file.mkdir( buildDirectory );
\ No newline at end of file
+grunt.file.mkdir( buildDirectory );
+
+process.env;
+process.blarg;
+
+document.hello;
+window.hello;
+global.hello;
+
+global.process;
+global.hello;
+
+window.location;
+
+const myDiv = document.createElement( 'div' );
+console.log( myDiv );
\ No newline at end of file
Index: tsconfig-supercore.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig-supercore.json b/tsconfig-supercore.json
new file mode 100644
--- /dev/null (date 1726592123623)
+++ b/tsconfig-supercore.json (date 1726592123623)
@@ -0,0 +1,76 @@
+/**
+ * Shared defaults for tsconfig files.
+ * @author Sam Reid (PhET Interactive Simulations)
+ */
+{
+ "compilerOptions": {
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
+
+ /* Basic Options */
+ "incremental": true, /* Enable incremental compilation */
+ "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
+ "module": "ES2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
+ // "lib": [], /* Specify library files to be included in the compilation. */
+ "allowJs": true, /* Allow javascript files to be compiled. */
+ "checkJs": false, /* Report errors in .js files. */
+ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
+ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
+ "sourceMap": false, /* Generates corresponding '.map' file. */
+ "outDir": "../chipper/dist/tsc/outDir", /* Redirect output structure to the directory. */
+ "rootDir": "../", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
+ "composite": false, /* Enable project compilation (project references) */
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
+ // "removeComments": true, /* Do not emit comments to output. */
+ "noEmit": false, /* Emit outputs. */
+ "emitDeclarationOnly": true, /* But not js output, because we use babel ourselves */
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
+ "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
+
+ /* Strict Type-Checking Options */
+ "strict": true, /* Enable all strict type-checking options. */
+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
+ // "strictNullChecks": true, /* Enable strict null checks. */
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
+ /* Additional Checks */
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
+ "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
+ "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
+ // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
+
+ /* Module Resolution Options */
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
+ // "typeRoots": [], /* List of folders to include type definitions from. */
+ // "types": [], /* Type declaration files to be included in compilation. */
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
+ // "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
+ "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
+
+ /* Source Map Options */
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
+
+ /* Experimental Options */
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
+
+ /* Advanced Options */
+ "skipLibCheck": true, /* Skip type checking of declaration files. */
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
+ }
+}
\ No newline at end of file
Index: tsconfig-core.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tsconfig-core.json b/tsconfig-core.json
--- a/tsconfig-core.json (revision ce419be8db96fdfa2883db184e96eba02b056900)
+++ b/tsconfig-core.json (date 1726592666014)
@@ -3,75 +3,11 @@
* @author Sam Reid (PhET Interactive Simulations)
*/
{
+ "extends": "./tsconfig-supercore.json",
"compilerOptions": {
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
-
- /* Basic Options */
- "incremental": true, /* Enable incremental compilation */
- "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
- "module": "ES2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
- // "lib": [], /* Specify library files to be included in the compilation. */
- "allowJs": true, /* Allow javascript files to be compiled. */
- "checkJs": false, /* Report errors in .js files. */
- "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
- "declaration": true, /* Generates corresponding '.d.ts' file. */
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
- "sourceMap": false, /* Generates corresponding '.map' file. */
- "outDir": "../chipper/dist/tsc/outDir", /* Redirect output structure to the directory. */
- "rootDir": "../", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
- "composite": false, /* Enable project compilation (project references) */
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
- // "removeComments": true, /* Do not emit comments to output. */
- "noEmit": false, /* Emit outputs. */
- "emitDeclarationOnly": true, /* But not js output, because we use babel ourselves */
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
- "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
-
- /* Strict Type-Checking Options */
- "strict": true, /* Enable all strict type-checking options. */
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
- // "strictNullChecks": true, /* Enable strict null checks. */
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
- /* Additional Checks */
- // "noUnusedLocals": true, /* Report errors on unused locals. */
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
- "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
- "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
- // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
-
- /* Module Resolution Options */
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
- // "typeRoots": [], /* List of folders to include type definitions from. */
- // "types": [], /* Type declaration files to be included in compilation. */
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
- // "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
- "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
-
- /* Source Map Options */
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
-
- /* Experimental Options */
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
-
- /* Advanced Options */
- "skipLibCheck": true, /* Skip type checking of declaration files. */
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
+ "lib": [
+ "DOM"
+ ]
},
"files": [
"phet-types.d.ts",
Index: js/grunt/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/tsconfig.json b/js/grunt/tsconfig.json
new file mode 100644
--- /dev/null (date 1726591845136)
+++ b/js/grunt/tsconfig.json (date 1726591845136)
@@ -0,0 +1,6 @@
+{
+ "extends": "../../tsconfig-node.json",
+ "include": [
+ "**/*"
+ ]
+}
\ No newline at end of file |
After reverting the patch, I made minor updates until lint-everything and tsc all were passing. It seems we are in a good spot to merge this branch to main, then continue in a subsequent issue and a new branch. |
I merged the above commits to main and pushed. I described on slack for other developers to pull and npm update in chipper. I'll open a new issue + new branch for next steps. |
Signed-off-by: Michael Kauzmann <[email protected]>
One more path bug fix above. |
Still some TODOs here |
I moved TODOs to the right side issues. The only two left here are above how we want to support tsx for scripts. Can we make a separate issue for that also? Like perennial/scripts/pull-all.sh. |
I addressed another TODO and opened side issues. This one can be closed. |
From an idea in #1437, we could use grunt as a thin wrapper that spawns a new process in a runtime under our control. This will help us modularize and isolate our dependence on grunt, and allow us flexibility to use alternate runtimes such as
tsx
and TypeScript.npx ../chipper/node_modules/.bin/tsx
"allowSyntheticDefaultImports": true
oresModuleInterop
for imports?Move chipper/js/grunt/tasks/ files to chipper/js/tasks?Move chipper/js/grunt files elsewhere? So the only thing there would be Gruntfile.jsThe text was updated successfully, but these errors were encountered: