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

Generalize the wrapPath API in requireBuild.js #770

Closed
samreid opened this issue Jul 12, 2019 · 2 comments
Closed

Generalize the wrapPath API in requireBuild.js #770

samreid opened this issue Jul 12, 2019 · 2 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Jul 12, 2019

From #764

Improvements were made in requireBuild.wrapPath in #764 but we can take one more step to improve it further. Here's an (untested) change that uses the requirejs API for setting the wrap. This is better because it consolidates the wrap information and reuses the requirejs API instead of creating a different, more limited API.

Index: js/grunt/buildRunnable.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/grunt/buildRunnable.js	(revision 7eb2ddb2b66bdc53676cc6bc586cbee2d7b67201)
+++ js/grunt/buildRunnable.js	(date 1562941432000)
@@ -73,7 +73,10 @@
     insertRequire: repo + '-main',
     instrument: instrument,
     brand: brand,
-    wrapPath: 'phet.chipper.runRequireJS'
+    wrap: {
+      start: 'phet.chipper.runRequireJS = function(){',
+      end: '};'
+    }
   } );
 
   // Debug version is independent of passed in minifyOptions.  PhET-iO brand is minified, but leaves assertions & logging.
Index: js/grunt/requireBuild.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/grunt/requireBuild.js	(revision 7eb2ddb2b66bdc53676cc6bc586cbee2d7b67201)
+++ js/grunt/requireBuild.js	(date 1562941445000)
@@ -26,10 +26,7 @@
 module.exports = function( repo, mainConfigFile, options ) {
 
   const {
-    // {string|null} - If provided, the contents of the require.js build will be wrapped inside a function that is
-    // assigned to the given path (e.g. phet.chipper.runRequireJS).
-    wrapPath = null,
-
+    wrap = false, // same as requirejs api
     insertRequire = false,
     instrument = false,
     brand = 'phet'
@@ -57,10 +54,7 @@
 
       optimize: 'none',
 
-      wrap: wrapPath ? {
-        start: `${wrapPath} = function() {`,
-        end: '};'
-      } : false,
+      wrap: wrap,
 
       // Avoid optimization names that are outside the baseUrl, see http://requirejs.org/docs/optimization.html#pitfalls
       paths: {
@jonathanolson
Copy link
Contributor

I like that change. Implemented above, with an additional link to where the documentation for it lives.

@samreid
Copy link
Member Author

samreid commented Jul 27, 2019

Excellent, thanks! Closing.

@samreid samreid closed this as completed Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants