Skip to content
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

Use js/npm-dependencies to share npm modules across repos #372

Closed
2 of 3 tasks
zepumph opened this issue Oct 15, 2024 · 21 comments
Closed
2 of 3 tasks

Use js/npm-dependencies to share npm modules across repos #372

zepumph opened this issue Oct 15, 2024 · 21 comments

Comments

@zepumph
Copy link
Member

zepumph commented Oct 15, 2024

From phetsims/chipper#1464 we worked on a pattern to limit the propagation of the same npm modules across repos. Since we already support perennial-alias for imports from build tools like chipper/, it makes sense for them to be here.

  • Go through usages of devDependencies and dependencies to see what can just live in perennial and be used elsewhere (aqua/alpenglow/monday/chipper/etc).

  • Look at usages of importing from perennial/node_modules directly (and alias). This pattern supercedes that one.

  • Can we import lodash from perennial-alias in sims instead of using the global? That seems scary, but we should run an experiment to see if it is buggy. Hopefully it throws a loud error.

Note this issue is in the general them of moving code from chipper to perennial, like in #364 and phetsims/chipper#1489

@samreid
Copy link
Member

samreid commented Oct 15, 2024

This won't work until we have better entry point coverage. Here is a patch:

Subject: [PATCH] Rename import-shared => npm-dependencies, see https://github.com/phetsims/perennial/issues/372
---
Index: aqua/js/grunt/tasks/ct-node-client.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/aqua/js/grunt/tasks/ct-node-client.ts b/aqua/js/grunt/tasks/ct-node-client.ts
--- a/aqua/js/grunt/tasks/ct-node-client.ts	(revision d71149fdc1a1dce159a383e90ca9464fbae3e854)
+++ b/aqua/js/grunt/tasks/ct-node-client.ts	(date 1729024366708)
@@ -13,7 +13,7 @@
 import assert from 'assert';
 import getOption from '../../../../perennial/js/grunt/tasks/util/getOption';
 import winston from '../../../../perennial/js/npm-dependencies/winston';
-import playwright from '../../../../perennial/node_modules/playwright';
+import playwright from '../../../../perennial/js/npm-dependencies/playwright';
 import runNextTest from '../../node-client/runNextTest';
 
 winston.default.transports.console.level = 'info';
Index: aqua/js/node-client/runTest.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/aqua/js/node-client/runTest.js b/aqua/js/node-client/runTest.js
--- a/aqua/js/node-client/runTest.js	(revision d71149fdc1a1dce159a383e90ca9464fbae3e854)
+++ b/aqua/js/node-client/runTest.js	(date 1729026420232)
@@ -8,7 +8,8 @@
 
 const _ = require( 'lodash' );
 const sendTestResult = require( './sendTestResult' );
-const puppeteer = require( '../../../perennial/node_modules/puppeteer' );
+// eslint-disable-next-line phet/no-property-in-require-statement
+const puppeteer = require( '../../../perennial/js/npm-dependencies/puppeteer' ).default;
 const browserPageLoad = require( '../../../perennial/js/common/browserPageLoad' );
 const winston = require( 'winston' );
 const path = require( 'path' );
Index: perennial/js/npm-dependencies/playwright.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/js/npm-dependencies/playwright.js b/perennial/js/npm-dependencies/playwright.js
new file mode 100644
--- /dev/null	(date 1729024370310)
+++ b/perennial/js/npm-dependencies/playwright.js	(date 1729024370310)
@@ -0,0 +1,11 @@
+// Copyright 2024, University of Colorado Boulder
+
+/**
+ * To be used when trying to import playwright from other repos.
+ *
+ * @author Michael Kauzmann (PhET Interactive Simulations)
+ */
+
+import playwright from 'playwright';
+
+export default playwright;
\ No newline at end of file
Index: phet-info/project-management/reportEpicIssuesNotInSpreadsheet.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phet-info/project-management/reportEpicIssuesNotInSpreadsheet.js b/phet-info/project-management/reportEpicIssuesNotInSpreadsheet.js
--- a/phet-info/project-management/reportEpicIssuesNotInSpreadsheet.js	(revision 9cfcb3e641fc5bf02cc89054365259cf74c1b29f)
+++ b/phet-info/project-management/reportEpicIssuesNotInSpreadsheet.js	(date 1729026163032)
@@ -20,7 +20,8 @@
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 
-const _ = require( '../../perennial/node_modules/lodash' );
+// eslint-disable-next-line phet/no-property-in-require-statement
+const _ = require( '../../perennial/js/npm-dependencies/lodash' ).default;
 const buildLocal = require( '../../perennial/js/common/buildLocal' );
 const https = require( 'https' );
 
Index: aqua/js/server/playwrightCTClient.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/aqua/js/server/playwrightCTClient.js b/aqua/js/server/playwrightCTClient.js
--- a/aqua/js/server/playwrightCTClient.js	(revision d71149fdc1a1dce159a383e90ca9464fbae3e854)
+++ b/aqua/js/server/playwrightCTClient.js	(date 1729026109777)
@@ -9,7 +9,8 @@
 const assert = require( 'assert' );
 const playwrightLoad = require( '../../../perennial/js/common/playwrightLoad' );
 const { parentPort } = require( 'worker_threads' ); // eslint-disable-line phet/require-statement-match
-const playwright = require( '../../../perennial/node_modules/playwright' );
+// eslint-disable-next-line phet/no-property-in-require-statement
+const playwright = require( '../../../perennial/js/npm-dependencies/playwright' ).default;
 
 process.on( 'SIGINT', () => process.exit() );
 
Index: perennial/js/npm-dependencies/axios.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/js/npm-dependencies/axios.js b/perennial/js/npm-dependencies/axios.js
new file mode 100644
--- /dev/null	(date 1729024467523)
+++ b/perennial/js/npm-dependencies/axios.js	(date 1729024467523)
@@ -0,0 +1,11 @@
+// Copyright 2024, University of Colorado Boulder
+
+/**
+ * To be used when trying to import axios from other repos.
+ *
+ * @author Michael Kauzmann (PhET Interactive Simulations)
+ */
+
+import axios from 'axios';
+
+export default axios;
\ No newline at end of file
Index: perennial/js/npm-dependencies/puppeteer.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/js/npm-dependencies/puppeteer.js b/perennial/js/npm-dependencies/puppeteer.js
new file mode 100644
--- /dev/null	(date 1729024427352)
+++ b/perennial/js/npm-dependencies/puppeteer.js	(date 1729024427352)
@@ -0,0 +1,11 @@
+// Copyright 2024, University of Colorado Boulder
+
+/**
+ * To be used when trying to import puppeteer from other repos.
+ *
+ * @author Michael Kauzmann (PhET Interactive Simulations)
+ */
+
+import puppeteer from 'puppeteer';
+
+export default puppeteer;
\ No newline at end of file
Index: phet-io/js/scripts/print-public-sim-versions.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phet-io/js/scripts/print-public-sim-versions.js b/phet-io/js/scripts/print-public-sim-versions.js
--- a/phet-io/js/scripts/print-public-sim-versions.js	(revision 2d13454302d40e6a9b5258d1c07f34e85a9a0f79)
+++ b/phet-io/js/scripts/print-public-sim-versions.js	(date 1729024636251)
@@ -20,7 +20,8 @@
 const ReleaseBranch = require( '../../../perennial/js/common/ReleaseBranch' );
 const gitCheckoutDirectory = require( '../../../perennial/js/common/gitCheckoutDirectory' );
 const loadJSON = require( '../../../perennial/js/common/loadJSON' );
-const _ = require( '../../../perennial/node_modules/lodash' );
+// eslint-disable-next-line phet/no-property-in-require-statement
+const _ = require( '../../../perennial/js/npm-dependencies/lodash' ).default;
 
 ( async () => {
 
Index: phet-info/github-labels/update-repos-list.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/phet-info/github-labels/update-repos-list.js b/phet-info/github-labels/update-repos-list.js
--- a/phet-info/github-labels/update-repos-list.js	(revision 9cfcb3e641fc5bf02cc89054365259cf74c1b29f)
+++ b/phet-info/github-labels/update-repos-list.js	(date 1729026134453)
@@ -6,7 +6,8 @@
 //  a newline separated list of all repos in the phetsims organization.
 // @author Matt Pennington (PhET Interactive Simulations)
 
-const axios = require( '../../perennial/node_modules/axios' );
+// eslint-disable-next-line phet/no-property-in-require-statement
+const axios = require( '../../perennial/js/npm-dependencies/axios' ).default;
 const buildLocal = require( '../../perennial/js/common/buildLocal' );
 const fs = require( 'fs' );
 

We get this kind of problem:

~/phet/root/aqua$ node js/node-client/runTest.js 
(node:25749) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/samreid/phet/root/perennial/js/npm-dependencies/puppeteer.js:9
import puppeteer from 'puppeteer';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1469:18)
    at Module._compile (node:internal/modules/cjs/loader:1491:20)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:125:16)
    at Object.<anonymous> (/Users/samreid/phet/root/aqua/js/node-client/runTest.js:12:19)

Node.js v22.6.0

tsx entry is one way to resolve it.

@samreid samreid removed their assignment Oct 15, 2024
@zepumph
Copy link
Member Author

zepumph commented Oct 18, 2024

Seems very reasonable. On hold until we are done with phetsims/chipper#1481.

@zepumph
Copy link
Member Author

zepumph commented Nov 1, 2024

I'm working on this for puppeteer right now.

@zepumph
Copy link
Member Author

zepumph commented Nov 1, 2024

This should not be a lint error:

const _ = require( '../../../perennial/js/npm-dependencies/lodash.js' ).default;

Updating the rule now.

@zepumph zepumph self-assigned this Nov 4, 2024
@samreid samreid assigned samreid and unassigned zepumph Nov 6, 2024
samreid added a commit that referenced this issue Nov 6, 2024
samreid added a commit to phetsims/chipper that referenced this issue Nov 6, 2024
samreid added a commit to phetsims/chipper that referenced this issue Nov 7, 2024
@samreid
Copy link
Member

samreid commented Nov 7, 2024

After removing axios and puppeteer, most remaining chipper dependencies are appropriate - single usage and not declared in other repos elsewhere. One exception is "lodash" but removing lodash from package.json then running rm -rf node_modules and npm i node_modules brings back lodash anyways, perhaps a different npm dependency brings it along?

@samreid
Copy link
Member

samreid commented Nov 7, 2024

I'm struggling with lodash:

Subject: [PATCH] Use perennial-alias puppeteer, see https://github.com/phetsims/perennial/issues/372
---
Index: js/grunt/generateTestHTML.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/generateTestHTML.ts b/js/grunt/generateTestHTML.ts
--- a/js/grunt/generateTestHTML.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/generateTestHTML.ts	(date 1730946693368)
@@ -6,7 +6,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 const generateDevelopmentHTML = require( './generateDevelopmentHTML.js' );
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 
Index: js/phet-io/phetioCompareAPISets.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/phet-io/phetioCompareAPISets.js b/js/phet-io/phetioCompareAPISets.js
--- a/js/phet-io/phetioCompareAPISets.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/phet-io/phetioCompareAPISets.js	(date 1730946837427)
@@ -6,7 +6,7 @@
 
 const fs = require( 'fs' );
 const phetioCompareAPIs = require( './phetioCompareAPIs.js' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const jsondiffpatch = require( '../../../sherpa/lib/jsondiffpatch-v0.3.11.umd' ).create( {} );
 const assert = require( 'assert' );
 
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 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/tasks/update.ts	(date 1730946837424)
@@ -16,6 +16,7 @@
 import * as grunt from 'grunt';
 import getRepo from '../../../../perennial-alias/js/grunt/tasks/util/getRepo';
 import generateREADME from '../generateREADME';
+import _ from '../../../../perennial-alias/js/npm-dependencies/lodash.js';
 
 const generateDevelopmentHTML = require( '../generateDevelopmentHTML.js' );
 const generateA11yViewHTML = require( '../generateA11yViewHTML.js' );
@@ -27,8 +28,6 @@
 
 const packageObject = grunt.file.readJSON( `../${repo}/package.json` );
 
-const _ = require( 'lodash' );
-
 // support repos that don't have a phet object
 if ( !packageObject.phet ) {
 
Index: js/grunt/getThirdPartyLibEntries.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getThirdPartyLibEntries.ts b/js/grunt/getThirdPartyLibEntries.ts
--- a/js/grunt/getThirdPartyLibEntries.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getThirdPartyLibEntries.ts	(date 1730946693385)
@@ -13,7 +13,7 @@
 import getLicenseKeys from './getLicenseKeys';
 
 // modules
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const grunt = require( 'grunt' );
 
Index: js/grunt/copyDirectory.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/copyDirectory.js b/js/grunt/copyDirectory.js
--- a/js/grunt/copyDirectory.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/copyDirectory.js	(date 1730946693377)
@@ -7,7 +7,7 @@
  * @author Sam Reid (PhET Interactive Simulations)
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const grunt = require( 'grunt' );
 const minify = require( './minify.js' );
Index: js/grunt/webpackBuild.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/webpackBuild.ts b/js/grunt/webpackBuild.ts
--- a/js/grunt/webpackBuild.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/webpackBuild.ts	(date 1730946837417)
@@ -7,7 +7,7 @@
  */
 
 import * as fs from 'fs';
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import * as path from 'path';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import * as ChipperConstants from '../common/ChipperConstants.js';
Index: js/common/Transpiler.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/Transpiler.js b/js/common/Transpiler.js
--- a/js/common/Transpiler.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/common/Transpiler.js	(date 1730946693434)
@@ -22,7 +22,7 @@
 const webpackGlobalLibraries = require( './webpackGlobalLibraries.js' );
 const core = require( '@babel/core' );
 const assert = require( 'assert' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // Cache status is stored in chipper/dist so if you wipe chipper/dist you also wipe the cache
 const statusPath = '../chipper/dist/js-cache-status.json';
Index: js/grunt/profileFileSize.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/profileFileSize.ts b/js/grunt/profileFileSize.ts
--- a/js/grunt/profileFileSize.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/profileFileSize.ts	(date 1730946693373)
@@ -14,7 +14,7 @@
 const fs = require( 'fs' );
 const zlib = require( 'zlib' );
 
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 
 export default async function( repo: string ): Promise<void> {
   const file = fs.readFileSync( `../${repo}/build/phet/${repo}_all_phet.html`, 'utf-8' );
Index: js/common/stringEncoding.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/stringEncoding.js b/js/common/stringEncoding.js
--- a/js/common/stringEncoding.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/common/stringEncoding.js	(date 1730946693418)
@@ -30,7 +30,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const toLessEscapedString = require( './toLessEscapedString.js' );
 
 const PUSH_TOKEN = '\u0001'; // push string on the stack
Index: js/grunt/getLicenseKeys.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getLicenseKeys.ts b/js/grunt/getLicenseKeys.ts
--- a/js/grunt/getLicenseKeys.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getLicenseKeys.ts	(date 1730946693414)
@@ -9,7 +9,7 @@
 
 import getPreloads from './getPreloads.js';
 
-const _ = require( 'lodash' );
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 const webpackGlobalLibraries = require( '../common/webpackGlobalLibraries.js' );
 const grunt = require( 'grunt' );
 
Index: js/grunt/copySupplementalPhetioFiles.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/copySupplementalPhetioFiles.ts b/js/grunt/copySupplementalPhetioFiles.ts
--- a/js/grunt/copySupplementalPhetioFiles.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/copySupplementalPhetioFiles.ts	(date 1730946693364)
@@ -9,7 +9,7 @@
  */
 
 import * as fs from 'fs';
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import webpackBuild from './webpackBuild.ts';
 import buildStandalone from './buildStandalone.ts';
Index: js/grunt/minify.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/minify.js b/js/grunt/minify.js
--- a/js/grunt/minify.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/minify.js	(date 1730946693429)
@@ -8,7 +8,7 @@
 
 
 // modules
-const _ = require( 'lodash' );
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 const transpileForBuild = require( './transpileForBuild.js' );
 const terser = require( 'terser' );
 
Index: js/test-browser-lint.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/test-browser-lint.ts b/js/test-browser-lint.ts
--- a/js/test-browser-lint.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/test-browser-lint.ts	(date 1730946530002)
@@ -19,6 +19,6 @@
   console.log( process );
 
   // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports,no-undef
-  const lodash = require( 'lodash' );
+  const lodash = require( '../../perennial-alias/js/npm-dependencies/lodash.js' );
   console.log( lodash );
 } )();
\ No newline at end of file
Index: js/grunt/getPreloads.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getPreloads.ts b/js/grunt/getPreloads.ts
--- a/js/grunt/getPreloads.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getPreloads.ts	(date 1730946693388)
@@ -1,6 +1,6 @@
 // Copyright 2017-2024, University of Colorado Boulder
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import assert from 'assert';
 import * as grunt from 'grunt';
 import ChipperStringUtils from '../common/ChipperStringUtils';
Index: js/grunt/gruntMain.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/gruntMain.js b/js/grunt/gruntMain.js
--- a/js/grunt/gruntMain.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/gruntMain.js	(date 1730946693393)
@@ -15,7 +15,7 @@
 require( './checkNodeVersion' );
 const registerTasks = require( '../../../perennial-alias/js/grunt/util/registerTasks.js' );
 const gruntSpawn = require( '../../../perennial-alias/js/grunt/util/gruntSpawn.js' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // Allow other Gruntfiles to potentially handle exiting and errors differently
 if ( !global.processEventOptOut ) {
Index: js/grunt/getPrunedLocaleData.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getPrunedLocaleData.js b/js/grunt/getPrunedLocaleData.js
--- a/js/grunt/getPrunedLocaleData.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getPrunedLocaleData.js	(date 1730946693410)
@@ -6,7 +6,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const fs = require( 'fs' );
 
Index: js/scripts/transpile-swc.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/scripts/transpile-swc.ts b/js/scripts/transpile-swc.ts
--- a/js/scripts/transpile-swc.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/scripts/transpile-swc.ts	(date 1730946837404)
@@ -12,7 +12,7 @@
  */
 
 import { spawn } from 'child_process';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import path from 'path';
 import getActiveRepos from '../../../perennial-alias/js/common/getActiveRepos';
 
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 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/package.json	(date 1730946399458)
@@ -33,7 +33,6 @@
     "jimp": "~0.16.1",
     "jpeg-js": "~0.4.3",
     "jsdoc": "~3.6.7",
-    "lodash": "~4.17.21",
     "marked": "~4.0.1",
     "modify-source-webpack-plugin": "~4.1.0",
     "node-html-encoder": "~0.0.2",
Index: js/common/ChipperStringUtils.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/ChipperStringUtils.js b/js/common/ChipperStringUtils.js
--- a/js/common/ChipperStringUtils.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/common/ChipperStringUtils.js	(date 1730946529997)
@@ -8,7 +8,7 @@
  */
 
 const assert = require( 'assert' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // What divides the repo prefix from the rest of the string key, like `FRICTION/friction.title`
 const NAMESPACE_PREFIX_DIVIDER = '/';
Index: js/grunt/transpile.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/transpile.ts b/js/grunt/transpile.ts
--- a/js/grunt/transpile.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/transpile.ts	(date 1730946837421)
@@ -1,7 +1,7 @@
 // Copyright 2024, University of Colorado Boulder
 
 import assert from 'assert';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import { Repo } from '../../../perennial-alias/js/common/PerennialTypes.js';
 import getOption from '../../../perennial-alias/js/grunt/tasks/util/getOption.js';
 import getRepo, { getRepos } from '../../../perennial-alias/js/grunt/tasks/util/getRepo.js';
Index: js/grunt/modulify.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/modulify.ts b/js/grunt/modulify.ts
--- a/js/grunt/modulify.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/modulify.ts	(date 1730946837410)
@@ -11,7 +11,8 @@
 import getCopyrightLine from './getCopyrightLine';
 import createMipmap from './createMipmap.js';
 
-const _ = require( 'lodash' );
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
+
 const fs = require( 'fs' );
 const path = require( 'path' );
 const grunt = require( 'grunt' );
@@ -338,6 +339,7 @@
     return Object.keys( spec[ regionAndCulture ] );
   } ) ).sort();
 
+  // @ts-expect-error
   const imageFiles: string[] = _.uniq( providedRegionsAndCultures.flatMap( regionAndCulture => {
     return Object.values( spec[ regionAndCulture ] );
   } ) ).sort();
Index: js/grunt/buildStandalone.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/buildStandalone.ts b/js/grunt/buildStandalone.ts
--- a/js/grunt/buildStandalone.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/buildStandalone.ts	(date 1730946693422)
@@ -10,12 +10,12 @@
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.ts';
 import getLocalesFromRepository from './getLocalesFromRepository';
 import getPhetLibs from './getPhetLibs.js';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 
 const assert = require( 'assert' );
 const fs = require( 'fs' );
 const grunt = require( 'grunt' );
 const minify = require( './minify.js' );
-const _ = require( 'lodash' );
 const getStringMap = require( './getStringMap.js' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 
Index: js/grunt/generateDevelopmentHTML.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/generateDevelopmentHTML.ts b/js/grunt/generateDevelopmentHTML.ts
--- a/js/grunt/generateDevelopmentHTML.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/generateDevelopmentHTML.ts	(date 1730946693439)
@@ -9,7 +9,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import fixEOL from '../../../perennial-alias/js/common/fixEOL.js';
 import getPreloads from './getPreloads';
Index: js/common/showCommandLineProgress.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/showCommandLineProgress.js b/js/common/showCommandLineProgress.js
--- a/js/common/showCommandLineProgress.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/common/showCommandLineProgress.js	(date 1730946693339)
@@ -6,7 +6,7 @@
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 /**
  * See https://jagascript.com/how-to-build-a-textual-progress-bar-for-cli-and-terminal-apps/
Index: js/common/pascalCase.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/pascalCase.js b/js/common/pascalCase.js
--- a/js/common/pascalCase.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/common/pascalCase.js	(date 1730946693426)
@@ -1,6 +1,6 @@
 // Copyright 2022-2024, University of Colorado Boulder
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 /**
  * Convert a string to PascalCase
Index: js/grunt/reportThirdParty.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/reportThirdParty.js b/js/grunt/reportThirdParty.js
--- a/js/grunt/reportThirdParty.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/reportThirdParty.js	(date 1730946693382)
@@ -19,7 +19,7 @@
  */
 
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const fs = require( 'fs' );
Index: js/grunt/buildRunnable.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/buildRunnable.ts b/js/grunt/buildRunnable.ts
--- a/js/grunt/buildRunnable.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/buildRunnable.ts	(date 1730946693399)
@@ -7,7 +7,7 @@
  */
 
 import fs from 'fs';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import * as ChipperConstants from '../common/ChipperConstants';
 import generateThumbnails from './generateThumbnails';
 import generateTwitterCard from './generateTwitterCard';
Index: js/grunt/updateCopyrightDates.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/updateCopyrightDates.ts b/js/grunt/updateCopyrightDates.ts
--- a/js/grunt/updateCopyrightDates.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/updateCopyrightDates.ts	(date 1730946837430)
@@ -8,7 +8,7 @@
  */
 
 import * as grunt from 'grunt';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import updateCopyrightDate from './updateCopyrightDate';
 
 const unsupportedExtensions = [ '.json', 'md' ];
Index: js/grunt/sortImports.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/sortImports.js b/js/grunt/sortImports.js
--- a/js/grunt/sortImports.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/sortImports.js	(date 1730946718390)
@@ -13,7 +13,7 @@
 
 
 // 3rd-party packages
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const fs = require( 'fs' );
 
 // constants
Index: js/grunt/getPhetLibs.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getPhetLibs.ts b/js/grunt/getPhetLibs.ts
--- a/js/grunt/getPhetLibs.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getPhetLibs.ts	(date 1730946693404)
@@ -9,7 +9,7 @@
 
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import assert from 'assert';
 import * as grunt from 'grunt';
 
Index: js/phet-io/phetioCompareAPIsTests.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/phet-io/phetioCompareAPIsTests.js b/js/phet-io/phetioCompareAPIsTests.js
--- a/js/phet-io/phetioCompareAPIsTests.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/phet-io/phetioCompareAPIsTests.js	(date 1730946837437)
@@ -8,7 +8,7 @@
 const qunit = require( 'qunit' );
 const assert = require( 'assert' );
 const _phetioCompareAPIs = require( './phetioCompareAPIs' ); // eslint-disable-line phet/require-statement-match
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 qunit.module( 'phetioCompareAPIs' );
 
Index: js/grunt/getStringMap.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/getStringMap.js b/js/grunt/getStringMap.js
--- a/js/grunt/getStringMap.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/getStringMap.js	(date 1730946693354)
@@ -8,7 +8,7 @@
  */
 
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const pascalCase = require( '../common/pascalCase.js' );
Index: js/grunt/test-node-lint.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/grunt/test-node-lint.ts b/js/grunt/test-node-lint.ts
--- a/js/grunt/test-node-lint.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/js/grunt/test-node-lint.ts	(date 1730946837413)
@@ -18,6 +18,6 @@
 
   console.log( process );
 
-  const lodash = require( 'lodash' );
-  console.log( lodash );
+  const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
+  console.log( _ );
 } )();
\ No newline at end of file
~/phet/root/density$ grunt
(node:14954) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
Loading "Gruntfile.js" tasks...ERROR
>> SyntaxError: Cannot use import statement outside a module
Warning: Task "default" not found. Use --force to continue.

Aborted due to warnings.

And I'm not convinced the call site is better, especially since there are so many.

import _ from 'lodash'
compared to
import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';

@samreid
Copy link
Member

samreid commented Nov 7, 2024

It works better if I change lodash.js from import to require (oops one tsc error sneaked in):

Subject: [PATCH] Use perennial-alias puppeteer, see https://github.com/phetsims/perennial/issues/372
---
Index: chipper/js/grunt/generateTestHTML.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/generateTestHTML.ts b/chipper/js/grunt/generateTestHTML.ts
--- a/chipper/js/grunt/generateTestHTML.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/generateTestHTML.ts	(date 1730946693368)
@@ -6,7 +6,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 const generateDevelopmentHTML = require( './generateDevelopmentHTML.js' );
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 
Index: chipper/js/phet-io/phetioCompareAPISets.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/phet-io/phetioCompareAPISets.js b/chipper/js/phet-io/phetioCompareAPISets.js
--- a/chipper/js/phet-io/phetioCompareAPISets.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/phet-io/phetioCompareAPISets.js	(date 1730946837427)
@@ -6,7 +6,7 @@
 
 const fs = require( 'fs' );
 const phetioCompareAPIs = require( './phetioCompareAPIs.js' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const jsondiffpatch = require( '../../../sherpa/lib/jsondiffpatch-v0.3.11.umd' ).create( {} );
 const assert = require( 'assert' );
 
Index: chipper/js/grunt/tasks/update.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/tasks/update.ts b/chipper/js/grunt/tasks/update.ts
--- a/chipper/js/grunt/tasks/update.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/tasks/update.ts	(date 1730947235223)
@@ -17,6 +17,8 @@
 import getRepo from '../../../../perennial-alias/js/grunt/tasks/util/getRepo';
 import generateREADME from '../generateREADME';
 
+const _ = require( '../../../../perennial-alias/js/npm-dependencies/lodash.js' );
+
 const generateDevelopmentHTML = require( '../generateDevelopmentHTML.js' );
 const generateA11yViewHTML = require( '../generateA11yViewHTML.js' );
 const generateTestHTML = require( '../generateTestHTML.js' );
@@ -27,8 +29,6 @@
 
 const packageObject = grunt.file.readJSON( `../${repo}/package.json` );
 
-const _ = require( 'lodash' );
-
 // support repos that don't have a phet object
 if ( !packageObject.phet ) {
 
Index: chipper/js/grunt/getThirdPartyLibEntries.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getThirdPartyLibEntries.ts b/chipper/js/grunt/getThirdPartyLibEntries.ts
--- a/chipper/js/grunt/getThirdPartyLibEntries.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getThirdPartyLibEntries.ts	(date 1730946693385)
@@ -13,7 +13,7 @@
 import getLicenseKeys from './getLicenseKeys';
 
 // modules
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const grunt = require( 'grunt' );
 
Index: chipper/js/grunt/copyDirectory.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/copyDirectory.js b/chipper/js/grunt/copyDirectory.js
--- a/chipper/js/grunt/copyDirectory.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/copyDirectory.js	(date 1730946693377)
@@ -7,7 +7,7 @@
  * @author Sam Reid (PhET Interactive Simulations)
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const grunt = require( 'grunt' );
 const minify = require( './minify.js' );
Index: chipper/js/grunt/webpackBuild.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/webpackBuild.ts b/chipper/js/grunt/webpackBuild.ts
--- a/chipper/js/grunt/webpackBuild.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/webpackBuild.ts	(date 1730946837417)
@@ -7,7 +7,7 @@
  */
 
 import * as fs from 'fs';
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import * as path from 'path';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import * as ChipperConstants from '../common/ChipperConstants.js';
Index: chipper/js/common/Transpiler.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/Transpiler.js b/chipper/js/common/Transpiler.js
--- a/chipper/js/common/Transpiler.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/common/Transpiler.js	(date 1730946693434)
@@ -22,7 +22,7 @@
 const webpackGlobalLibraries = require( './webpackGlobalLibraries.js' );
 const core = require( '@babel/core' );
 const assert = require( 'assert' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // Cache status is stored in chipper/dist so if you wipe chipper/dist you also wipe the cache
 const statusPath = '../chipper/dist/js-cache-status.json';
Index: chipper/js/grunt/profileFileSize.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/profileFileSize.ts b/chipper/js/grunt/profileFileSize.ts
--- a/chipper/js/grunt/profileFileSize.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/profileFileSize.ts	(date 1730946693373)
@@ -14,7 +14,7 @@
 const fs = require( 'fs' );
 const zlib = require( 'zlib' );
 
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 
 export default async function( repo: string ): Promise<void> {
   const file = fs.readFileSync( `../${repo}/build/phet/${repo}_all_phet.html`, 'utf-8' );
Index: chipper/js/common/stringEncoding.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/stringEncoding.js b/chipper/js/common/stringEncoding.js
--- a/chipper/js/common/stringEncoding.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/common/stringEncoding.js	(date 1730946693418)
@@ -30,7 +30,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const toLessEscapedString = require( './toLessEscapedString.js' );
 
 const PUSH_TOKEN = '\u0001'; // push string on the stack
Index: chipper/js/grunt/getLicenseKeys.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getLicenseKeys.ts b/chipper/js/grunt/getLicenseKeys.ts
--- a/chipper/js/grunt/getLicenseKeys.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getLicenseKeys.ts	(date 1730947330685)
@@ -9,7 +9,7 @@
 
 import getPreloads from './getPreloads.js';
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const webpackGlobalLibraries = require( '../common/webpackGlobalLibraries.js' );
 const grunt = require( 'grunt' );
 
Index: chipper/js/grunt/copySupplementalPhetioFiles.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/copySupplementalPhetioFiles.ts b/chipper/js/grunt/copySupplementalPhetioFiles.ts
--- a/chipper/js/grunt/copySupplementalPhetioFiles.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/copySupplementalPhetioFiles.ts	(date 1730946693364)
@@ -9,7 +9,7 @@
  */
 
 import * as fs from 'fs';
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import webpackBuild from './webpackBuild.ts';
 import buildStandalone from './buildStandalone.ts';
Index: chipper/js/grunt/minify.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/minify.js b/chipper/js/grunt/minify.js
--- a/chipper/js/grunt/minify.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/minify.js	(date 1730947235244)
@@ -8,7 +8,7 @@
 
 
 // modules
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const transpileForBuild = require( './transpileForBuild.js' );
 const terser = require( 'terser' );
 
Index: chipper/js/test-browser-lint.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/test-browser-lint.ts b/chipper/js/test-browser-lint.ts
--- a/chipper/js/test-browser-lint.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/test-browser-lint.ts	(date 1730946530002)
@@ -19,6 +19,6 @@
   console.log( process );
 
   // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports,no-undef
-  const lodash = require( 'lodash' );
+  const lodash = require( '../../perennial-alias/js/npm-dependencies/lodash.js' );
   console.log( lodash );
 } )();
\ No newline at end of file
Index: chipper/js/grunt/getPreloads.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getPreloads.ts b/chipper/js/grunt/getPreloads.ts
--- a/chipper/js/grunt/getPreloads.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getPreloads.ts	(date 1730946693388)
@@ -1,6 +1,6 @@
 // Copyright 2017-2024, University of Colorado Boulder
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import assert from 'assert';
 import * as grunt from 'grunt';
 import ChipperStringUtils from '../common/ChipperStringUtils';
Index: chipper/js/grunt/gruntMain.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/gruntMain.js b/chipper/js/grunt/gruntMain.js
--- a/chipper/js/grunt/gruntMain.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/gruntMain.js	(date 1730946693393)
@@ -15,7 +15,7 @@
 require( './checkNodeVersion' );
 const registerTasks = require( '../../../perennial-alias/js/grunt/util/registerTasks.js' );
 const gruntSpawn = require( '../../../perennial-alias/js/grunt/util/gruntSpawn.js' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // Allow other Gruntfiles to potentially handle exiting and errors differently
 if ( !global.processEventOptOut ) {
Index: chipper/js/grunt/getPrunedLocaleData.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getPrunedLocaleData.js b/chipper/js/grunt/getPrunedLocaleData.js
--- a/chipper/js/grunt/getPrunedLocaleData.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getPrunedLocaleData.js	(date 1730946693410)
@@ -6,7 +6,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const fs = require( 'fs' );
 
Index: chipper/js/scripts/transpile-swc.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/scripts/transpile-swc.ts b/chipper/js/scripts/transpile-swc.ts
--- a/chipper/js/scripts/transpile-swc.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/scripts/transpile-swc.ts	(date 1730946837404)
@@ -12,7 +12,7 @@
  */
 
 import { spawn } from 'child_process';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import path from 'path';
 import getActiveRepos from '../../../perennial-alias/js/common/getActiveRepos';
 
Index: chipper/package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/package.json b/chipper/package.json
--- a/chipper/package.json	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/package.json	(date 1730946399458)
@@ -33,7 +33,6 @@
     "jimp": "~0.16.1",
     "jpeg-js": "~0.4.3",
     "jsdoc": "~3.6.7",
-    "lodash": "~4.17.21",
     "marked": "~4.0.1",
     "modify-source-webpack-plugin": "~4.1.0",
     "node-html-encoder": "~0.0.2",
Index: chipper/js/common/ChipperStringUtils.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/ChipperStringUtils.js b/chipper/js/common/ChipperStringUtils.js
--- a/chipper/js/common/ChipperStringUtils.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/common/ChipperStringUtils.js	(date 1730946529997)
@@ -8,7 +8,7 @@
  */
 
 const assert = require( 'assert' );
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 // What divides the repo prefix from the rest of the string key, like `FRICTION/friction.title`
 const NAMESPACE_PREFIX_DIVIDER = '/';
Index: chipper/js/grunt/transpile.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/transpile.ts b/chipper/js/grunt/transpile.ts
--- a/chipper/js/grunt/transpile.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/transpile.ts	(date 1730946837421)
@@ -1,7 +1,7 @@
 // Copyright 2024, University of Colorado Boulder
 
 import assert from 'assert';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import { Repo } from '../../../perennial-alias/js/common/PerennialTypes.js';
 import getOption from '../../../perennial-alias/js/grunt/tasks/util/getOption.js';
 import getRepo, { getRepos } from '../../../perennial-alias/js/grunt/tasks/util/getRepo.js';
Index: chipper/js/grunt/modulify.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/modulify.ts b/chipper/js/grunt/modulify.ts
--- a/chipper/js/grunt/modulify.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/modulify.ts	(date 1730947235212)
@@ -11,7 +11,8 @@
 import getCopyrightLine from './getCopyrightLine';
 import createMipmap from './createMipmap.js';
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
+
 const fs = require( 'fs' );
 const path = require( 'path' );
 const grunt = require( 'grunt' );
@@ -338,6 +339,7 @@
     return Object.keys( spec[ regionAndCulture ] );
   } ) ).sort();
 
+  // @ts-expect-error
   const imageFiles: string[] = _.uniq( providedRegionsAndCultures.flatMap( regionAndCulture => {
     return Object.values( spec[ regionAndCulture ] );
   } ) ).sort();
Index: chipper/js/grunt/buildStandalone.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/buildStandalone.ts b/chipper/js/grunt/buildStandalone.ts
--- a/chipper/js/grunt/buildStandalone.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/buildStandalone.ts	(date 1730947235237)
@@ -11,11 +11,12 @@
 import getLocalesFromRepository from './getLocalesFromRepository';
 import getPhetLibs from './getPhetLibs.js';
 
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
+
 const assert = require( 'assert' );
 const fs = require( 'fs' );
 const grunt = require( 'grunt' );
 const minify = require( './minify.js' );
-const _ = require( 'lodash' );
 const getStringMap = require( './getStringMap.js' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 
Index: chipper/js/grunt/generateDevelopmentHTML.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/generateDevelopmentHTML.ts b/chipper/js/grunt/generateDevelopmentHTML.ts
--- a/chipper/js/grunt/generateDevelopmentHTML.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/generateDevelopmentHTML.ts	(date 1730946693439)
@@ -9,7 +9,7 @@
  * @author Jonathan Olson <[email protected]>
  */
 
-import * as _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
 import fixEOL from '../../../perennial-alias/js/common/fixEOL.js';
 import getPreloads from './getPreloads';
Index: chipper/js/common/showCommandLineProgress.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/showCommandLineProgress.js b/chipper/js/common/showCommandLineProgress.js
--- a/chipper/js/common/showCommandLineProgress.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/common/showCommandLineProgress.js	(date 1730946693339)
@@ -6,7 +6,7 @@
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 /**
  * See https://jagascript.com/how-to-build-a-textual-progress-bar-for-cli-and-terminal-apps/
Index: chipper/js/common/pascalCase.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/pascalCase.js b/chipper/js/common/pascalCase.js
--- a/chipper/js/common/pascalCase.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/common/pascalCase.js	(date 1730946693426)
@@ -1,6 +1,6 @@
 // Copyright 2022-2024, University of Colorado Boulder
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 /**
  * Convert a string to PascalCase
Index: chipper/js/grunt/reportThirdParty.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/reportThirdParty.js b/chipper/js/grunt/reportThirdParty.js
--- a/chipper/js/grunt/reportThirdParty.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/reportThirdParty.js	(date 1730946693382)
@@ -19,7 +19,7 @@
  */
 
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const fs = require( 'fs' );
Index: chipper/js/grunt/buildRunnable.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/buildRunnable.ts b/chipper/js/grunt/buildRunnable.ts
--- a/chipper/js/grunt/buildRunnable.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/buildRunnable.ts	(date 1730946693399)
@@ -7,7 +7,7 @@
  */
 
 import fs from 'fs';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import * as ChipperConstants from '../common/ChipperConstants';
 import generateThumbnails from './generateThumbnails';
 import generateTwitterCard from './generateTwitterCard';
Index: chipper/js/grunt/updateCopyrightDates.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/updateCopyrightDates.ts b/chipper/js/grunt/updateCopyrightDates.ts
--- a/chipper/js/grunt/updateCopyrightDates.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/updateCopyrightDates.ts	(date 1730946837430)
@@ -8,7 +8,7 @@
  */
 
 import * as grunt from 'grunt';
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import updateCopyrightDate from './updateCopyrightDate';
 
 const unsupportedExtensions = [ '.json', 'md' ];
Index: chipper/js/grunt/sortImports.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/sortImports.js b/chipper/js/grunt/sortImports.js
--- a/chipper/js/grunt/sortImports.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/sortImports.js	(date 1730946718390)
@@ -13,7 +13,7 @@
 
 
 // 3rd-party packages
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const fs = require( 'fs' );
 
 // constants
Index: chipper/js/grunt/getPhetLibs.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getPhetLibs.ts b/chipper/js/grunt/getPhetLibs.ts
--- a/chipper/js/grunt/getPhetLibs.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getPhetLibs.ts	(date 1730946693404)
@@ -9,7 +9,7 @@
 
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 
-import _ from 'lodash';
+import _ from '../../../perennial-alias/js/npm-dependencies/lodash.js';
 import assert from 'assert';
 import * as grunt from 'grunt';
 
Index: chipper/js/phet-io/phetioCompareAPIsTests.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/phet-io/phetioCompareAPIsTests.js b/chipper/js/phet-io/phetioCompareAPIsTests.js
--- a/chipper/js/phet-io/phetioCompareAPIsTests.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/phet-io/phetioCompareAPIsTests.js	(date 1730946837437)
@@ -8,7 +8,7 @@
 const qunit = require( 'qunit' );
 const assert = require( 'assert' );
 const _phetioCompareAPIs = require( './phetioCompareAPIs' ); // eslint-disable-line phet/require-statement-match
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 
 qunit.module( 'phetioCompareAPIs' );
 
Index: perennial-alias/js/npm-dependencies/lodash.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/npm-dependencies/lodash.js b/perennial-alias/js/npm-dependencies/lodash.js
--- a/perennial-alias/js/npm-dependencies/lodash.js	(revision d02f4e95a59fa44b705530f27c97d98324737ab5)
+++ b/perennial-alias/js/npm-dependencies/lodash.js	(date 1730947295137)
@@ -5,6 +5,9 @@
  * @author Michael Kauzmann (PhET Interactive Simulations)
  */
 
-import lodash from 'lodash';
+// import lodash from 'lodash';
+const lodash = require( 'lodash' );
+
+module.exports = lodash;
 
-export default lodash;
\ No newline at end of file
+// export default lodash;
\ No newline at end of file
Index: chipper/js/grunt/getStringMap.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/getStringMap.js b/chipper/js/grunt/getStringMap.js
--- a/chipper/js/grunt/getStringMap.js	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/getStringMap.js	(date 1730946693354)
@@ -8,7 +8,7 @@
  */
 
 
-const _ = require( 'lodash' );
+const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
 const assert = require( 'assert' );
 const ChipperConstants = require( '../common/ChipperConstants.js' );
 const pascalCase = require( '../common/pascalCase.js' );
Index: chipper/js/grunt/test-node-lint.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/test-node-lint.ts b/chipper/js/grunt/test-node-lint.ts
--- a/chipper/js/grunt/test-node-lint.ts	(revision 89723c241ab3c408e7b404b93c22a70cbb9eea75)
+++ b/chipper/js/grunt/test-node-lint.ts	(date 1730946837413)
@@ -18,6 +18,6 @@
 
   console.log( process );
 
-  const lodash = require( 'lodash' );
-  console.log( lodash );
+  const _ = require( '../../../perennial-alias/js/npm-dependencies/lodash.js' );
+  console.log( _ );
 } )();
\ No newline at end of file

It tests ok with grunt in density. @zepumph want to commit?

@samreid
Copy link
Member

samreid commented Nov 7, 2024

  • How do we do this for types?
import { BufferGeometry } from '../../../../perennial-alias/node_modules/@types/three/index.js';

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2024

  • We could use eslint's no-restricted-imports once this is complete to keep these from ending up back in spots like chipper and aqua.

@zepumph
Copy link
Member Author

zepumph commented Nov 8, 2024

Working on this now.

@samreid
Copy link
Member

samreid commented Nov 8, 2024

This patch "loses" a test. Any ideas?

Subject: [PATCH] Load JSON without grunt, see https://github.com/phetsims/chipper/issues/1491
---
Index: perennial-alias/js/npm-dependencies/qunit.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/npm-dependencies/qunit.js b/perennial-alias/js/npm-dependencies/qunit.js
new file mode 100644
--- /dev/null	(date 1731100758945)
+++ b/perennial-alias/js/npm-dependencies/qunit.js	(date 1731100758945)
@@ -0,0 +1,6 @@
+// Copyright 2024, University of Colorado Boulder
+/**
+ * @author Sam Reid (PhET Interactive Simulations)
+ */
+const qunit = require( 'qunit' );
+module.exports = qunit;
\ No newline at end of file
Index: chipper/js/common/ChipperStringUtilTests.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/common/ChipperStringUtilTests.js b/chipper/js/common/ChipperStringUtilTests.js
--- a/chipper/js/common/ChipperStringUtilTests.js	(revision 30db87da0b569316344f85faca97bcf6108c32b1)
+++ b/chipper/js/common/ChipperStringUtilTests.js	(date 1731100765615)
@@ -6,10 +6,9 @@
  */
 
 const ChipperStringUtils = require( './ChipperStringUtils.js' );
-const qunit = require( 'qunit' );
+const qunit = require( '../../../perennial-alias/js/npm-dependencies/qunit.js' );
 qunit.module( 'ChipperStringUtils' );
 
-
 qunit.test( 'forEachString', assert => {
   const map1 = {
     x: { value: 'x' },

Before the patch:

~/phet/root/chipper$ node node_modules/qunit/bin/qunit.js test/generalTests.js
TAP version 13
ok 1 ChipperStringUtils > forEachString
ok 2 phetioCompareAPIs > basics
ok 3 phetioCompareAPIs > designed changes
ok 4 phetioCompareAPIs > breaking element API changes
ok 5 phetioCompareAPIs > testing PhetioTypes
1..5
# pass 5
# skip 0
# todo 0
# fail 0

After the patch:

~/phet/root/chipper$ node node_modules/qunit/bin/qunit.js test/generalTests.js
TAP version 13
ok 1 phetioCompareAPIs > basics
ok 2 phetioCompareAPIs > designed changes
ok 3 phetioCompareAPIs > breaking element API changes
ok 4 phetioCompareAPIs > testing PhetioTypes
1..4
# pass 4
# skip 0
# todo 0
# fail 0

Any ideas?

@samreid samreid assigned zepumph and unassigned samreid Nov 8, 2024
samreid added a commit to phetsims/aqua that referenced this issue Nov 8, 2024
@samreid
Copy link
Member

samreid commented Nov 8, 2024

I removed puppeteer from aqua, and tested that grunt ct-node-client still worked ok.

@zepumph
Copy link
Member Author

zepumph commented Nov 13, 2024

Any ideas?

Yes, this makes sense, since you are registering just the one ChipperStringUtils test with a different copy of the qunit dependency. To proceed:

  1. Convert all usages that require qunit to use perennial
  2. Run your test from the perennial runnable
  3. Update chipper/package.json to run just like your command line test, using perennial/package.json "test" script as a guide.

@zepumph zepumph assigned samreid and unassigned zepumph Nov 13, 2024
samreid added a commit to phetsims/chipper that referenced this issue Nov 13, 2024
samreid added a commit that referenced this issue Nov 13, 2024
@samreid
Copy link
Member

samreid commented Nov 13, 2024

Thanks, I followed the strategy above and it worked well. For usages in perennial itself, do you want to go through require('qunit') or require('../npm-dependencies/qunit.js')? Probably the former is more idiomatic.

  • Why do we have 'no-restricted-imports': 'error',? Isn't that a no-op if you don't specify anything to restrict? Probably we should delete it.
  • With this patch, we get 21 complaints from rosetta, about winston (which is listed in rosetta package.json) and axios (which is not).
Subject: [PATCH] Add qunit to useNPMDependenciesFromPerennial.mjs, see https://github.com/phetsims/perennial/issues/372
---
Index: perennial-alias/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/eslint.config.mjs b/perennial-alias/eslint.config.mjs
--- a/perennial-alias/eslint.config.mjs	(revision 5a8b7e9bc13caced9ecbf981447b6a12c9c049aa)
+++ b/perennial-alias/eslint.config.mjs	(date 1731506244928)
@@ -12,7 +12,10 @@
     rules: {
 
       // There is a complication about importing phet-core from perennial, so until that is resolved, use `any` here instead
-      '@typescript-eslint/no-explicit-any': 'off' // TODO: Use IntentionalAny, https://github.com/phetsims/chipper/issues/1465
+      '@typescript-eslint/no-explicit-any': 'off', // TODO: Use IntentionalAny, https://github.com/phetsims/chipper/issues/1465
+
+      // Overrides useNPMDependenciesFromPerennial so that perennial can import its own node_modules
+      'no-restricted-imports': 'off'
     }
   }
 ];
\ No newline at end of file
Index: perennial-alias/js/eslint/config/root.eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial-alias/js/eslint/config/root.eslint.config.mjs b/perennial-alias/js/eslint/config/root.eslint.config.mjs
--- a/perennial-alias/js/eslint/config/root.eslint.config.mjs	(revision 5a8b7e9bc13caced9ecbf981447b6a12c9c049aa)
+++ b/perennial-alias/js/eslint/config/root.eslint.config.mjs	(date 1731504684110)
@@ -5,10 +5,11 @@
 import typescriptEslintParser from '@typescript-eslint/parser';
 import html from 'eslint-plugin-html';
 import globals from 'globals';
+import getNodeConfiguration from './util/getNodeConfiguration.mjs';
 import phetRulesPlugin from './util/phetRulesPlugin.mjs';
 import rootRules from './util/rootRules.mjs';
 import rootRulesTypeScript from './util/rootRulesTypeScript.mjs';
-import getNodeConfiguration from './util/getNodeConfiguration.mjs';
+import useNPMDependenciesFromPerennial from './util/useNPMDependenciesFromPerennial.mjs';
 
 /**
  * The base eslint configuration for the PhET projects.
@@ -160,5 +161,7 @@
     rules: {
       '@typescript-eslint/no-floating-promises': 'off'
     }
-  }
+  },
+
+  useNPMDependenciesFromPerennial
 ];
\ No newline at end of file
Index: chipper/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/eslint.config.mjs b/chipper/eslint.config.mjs
--- a/chipper/eslint.config.mjs	(revision d3a30cd4cb09b71227461d2b1c452c0c5f05e5d7)
+++ b/chipper/eslint.config.mjs	(date 1731504574691)
@@ -10,7 +10,6 @@
 import { getBrowserConfiguration } from '../perennial-alias/js/eslint/config/browser.eslint.config.mjs';
 import rootEslintConfig from '../perennial-alias/js/eslint/config/root.eslint.config.mjs';
 import getNodeConfiguration from '../perennial-alias/js/eslint/config/util/getNodeConfiguration.mjs';
-import useNPMDependenciesFromPerennial from '../perennial-alias/js/eslint/config/util/useNPMDependenciesFromPerennial.mjs';
 
 const browserFiles = [
   'js/*', // not recursive
@@ -29,6 +28,5 @@
       'phet/bad-chipper-text': 'error',
       '@typescript-eslint/no-explicit-any': 'off' // TODO: if we could use IntentionalAny. . . . https://github.com/phetsims/perennial/issues/371
     }
-  },
-  useNPMDependenciesFromPerennial
+  }
 ];
\ No newline at end of file
Index: aqua/eslint.config.mjs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/aqua/eslint.config.mjs b/aqua/eslint.config.mjs
--- a/aqua/eslint.config.mjs	(revision 56041a938cf9e550818de98fa7c72f44b9781e01)
+++ b/aqua/eslint.config.mjs	(date 1731504574699)
@@ -10,7 +10,6 @@
 import { getBrowserConfiguration } from '../perennial-alias/js/eslint/config/browser.eslint.config.mjs';
 import rootEslintConfig from '../perennial-alias/js/eslint/config/root.eslint.config.mjs';
 import getNodeConfiguration from '../perennial-alias/js/eslint/config/util/getNodeConfiguration.mjs';
-import useNPMDependenciesFromPerennial from '../perennial-alias/js/eslint/config/util/useNPMDependenciesFromPerennial.mjs';
 
 const nodeJSDirs = [
   'js/config/**',
@@ -28,7 +27,6 @@
   ...getNodeConfiguration( {
     files: nodeJSDirs
   } ),
-  useNPMDependenciesFromPerennial,
   {
     languageOptions: {
       globals: {

@zepumph
Copy link
Member Author

zepumph commented Nov 13, 2024

Probably the former is more idiomatic.

Agreed. Let's keep good style imports in perennial.

zepumph added a commit to phetsims/rosetta that referenced this issue Nov 13, 2024
zepumph added a commit that referenced this issue Nov 13, 2024
zepumph added a commit to phetsims/aqua that referenced this issue Nov 13, 2024
zepumph added a commit to phetsims/chipper that referenced this issue Nov 13, 2024
@zepumph
Copy link
Member Author

zepumph commented Nov 13, 2024

I committed your patch, but added it to getNodeConfiguration instead. I also just opted out in rosetta. It isn't clear to me that we should enforce that kind of thing over there. I'm open to it though. Anything else here?

@zepumph zepumph assigned samreid and unassigned zepumph Nov 13, 2024
@samreid
Copy link
Member

samreid commented Nov 15, 2024

That sounds good to me, just a spot check reminder that chipper should use perennial's grunt, especially for stateful things. We may be doing that as part of the fallout from #403 but I just wanted to make sure we didn't forget.

@samreid samreid removed their assignment Nov 15, 2024
@zepumph zepumph closed this as completed Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants