]> source.dussan.org Git - jquery.git/commitdiff
Build: Fix the regex parsing AMD var-modules (#4389)
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 13 May 2019 19:55:45 +0000 (21:55 +0200)
committerGitHub <noreply@github.com>
Mon, 13 May 2019 19:55:45 +0000 (21:55 +0200)
The previous regex caused the final jQuery binary to have syntax errors for
var-modules with names starting with "return". For example, the following module
wouldn't work when the file is named `returnTrue.js`:

```js
define( function() {
"use strict";
return function returnTrue() {
return true;
};
} );
```

Closes gh-4389

build/tasks/build.js

index 69916bf022041182a2ead105be52bcb20fddfb84..b59ef816ecb1ac56685d8a135775cf027292099d 100644 (file)
@@ -65,7 +65,7 @@ module.exports = function( grunt ) {
                if ( /.\/var\//.test( path.replace( process.cwd(), "" ) ) ) {
                        contents = contents
                                .replace(
-                                       /define\([\w\W]*?return/,
+                                       /define\(\s*(["'])[\w\W]*?\1[\w\W]*?return/,
                                        "var " +
                                        ( /var\/([\w-]+)/.exec( name )[ 1 ] ) +
                                        " ="