Skip to content

Commit

Permalink
feat(gcc): use goog.defines that are assigned to a value
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Schmidt committed Jan 28, 2020
1 parent 7c13187 commit a9a9638
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/gcc/defines.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const slash = require('slash');
*
* The nice thing about opensphere builds is that there is typically no need to re-run
* the build to pick up changes to JS or HTML (just hit refresh!). To accomplish
* this, each project has a goog.defines(<project>.ROOT, '../<project>/') call
* this, each project has a goog.define('<project>.ROOT', '../<project>/') call
* that allows you to prefix paths. e.g. an Angular directive with a template:
*
* {
Expand Down Expand Up @@ -85,7 +85,7 @@ const resolver = function(pack, projectDir, depth) {
}
};

return utils.findLines(/^goog\.define\(/, dir, /\.js$/).then(function(list) {
return utils.findLines(/goog\.define\(/, dir, /\.js$/).then(function(list) {
list.forEach(processItem);
});
}
Expand Down Expand Up @@ -161,7 +161,7 @@ const writer = function(thisPackage, outputDir) {
Object.assign(defs, modules);

// write out the debug file
var file = '// This file overrides goog.defines() calls for ' +
var file = '// This file overrides goog.define() calls for ' +
'<project>.*.ROOT defines in the debug html\nvar ' +
'CLOSURE_UNCOMPILED_DEFINES = ' + JSON.stringify(defs, null, 2) +
';';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["foo.ROOT='test'"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
goog.provide('foo');

/**
* @define {string}
*/
foo.ROOT = goog.define('foo.ROOT', '');
13 changes: 13 additions & 0 deletions test/plugins/gcc/defines/should-use-assigned-define/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "should-use-explicitly-defined-src-directory",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"build": {
"type": "app"
},
"directories": {
"src": "foo"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["foo.ROOT='test'"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
goog.module('foo');

/**
* @define {string}
*/
const ROOT = goog.define('foo.ROOT', '');

exports = {ROOT};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "should-use-explicitly-defined-src-directory",
"version": "1.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"build": {
"type": "app"
},
"directories": {
"src": "foo"
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
goog.provide('foo');

/**
* @define {string}
*/
goog.define('foo.ROOT', '');

0 comments on commit a9a9638

Please sign in to comment.