mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
refactor(build): Preparation for building TypeScript (#6205)
* chore(deps): Update closure/goog/base.js, add goog.js
- Update base.js from the latest version (20220502.0.0).
- Also copy over goog.js, which provides access to a suitable subset
of goog.* via an importable module).
* chore(build): Split gulpfiles/config.js exports object
This makes it possible for entries to depend on each other.
* chore(build): build config consistency
- Reorder entries in gulpfiles.config.js to better match order they
are used.
- Have update_metadata.sh reference config.js and vice versa.
* refactor(build): Move deps.js (+ deps.mocha.js) from test/ to build/
Once we start using tsc, deps.js will be created based on the ouptut
of tsc rather than the raw source in core/. Since tsc will need to
be run before running closure-make-deps and also before trying to
load blockly_uncompressed.js, it doesn't really make sense to check
in deps.js; it's better to re-create as needed.
To reduce inconvenience, a new "prepare" script is added to
package.json which will run the buildDeps gulp target automaticaly
when one runs npm install.
* refactor(build): Always build from TypeScript sources
- Add buildJavaScript gulp task to use tsc to compile any .ts files
in core/ into build/src/core/ (and also copy any .js files that
are not yet migrated to TypeScript, which for now is all of them.
- Remove closure/goog from explicit inputs to tsc; it will find
the files it needs (e.g., goog.js) automatically.
- Have buildDeps, the playground, and all the tests that run in
uncompiled mode use build/src/core/ instead of core/ as their
input directory.
* feat(build): Add buildJavaScriptAndDeps gulp task
Have npm run build:deps (and npm run prepare) use a new gulp task,
buildJavaScriptAndDeps, to run tsc followed by closure-make-deps,
ensuring that deps.js is calculated based on the most recent code
in core/.
* fix(build): Fix implementation of flattenCorePaths
Even though this function is going away I want to remove it in
a separate PR so that we can revert easily if desired. But the
previous checked-in code was totally wrong. This version works.
* fix(build): Don't let checkinBuilt copy build/src/**
Now that we are putting a lot more stuff in build/ (specifically,
all the tsc output in build/src/), modify checkinBuilt so that it
only copies the specific things we want to check in (for now):
- _compressed.js build artifacts and their accompanying .js.maps
- the generated build/msg/js/*.js language files.
Unrelatedly, also fix safety-quoting of arguments for one execSync
call.
This commit is contained in:
committed by
GitHub
parent
2a7d6b08b5
commit
307ff71c21
@@ -256,15 +256,15 @@ goog.LOCALE = goog.define('goog.LOCALE', 'en'); // default to en
|
||||
|
||||
|
||||
/**
|
||||
* This method is intended to be used for bookkeeping purposes. We would
|
||||
* like to distinguish uses of goog.LOCALE used for code stripping purposes
|
||||
* and uses of goog.LOCALE for other uses (such as URL parameters).
|
||||
* Same as `goog.LOCALE`, which should be used instead.
|
||||
*
|
||||
* This allows us to ban direct uses of goog.LOCALE and to ensure that all
|
||||
* code has been transformed to our new localization build scheme.
|
||||
* Using this method just makes it harder for closure-compiler to optimize
|
||||
* your locale-specific code, since it has to take the extra step of inlining
|
||||
* this function to discover and remove code that is not used for the target
|
||||
* locale.
|
||||
*
|
||||
* @return {string}
|
||||
*
|
||||
* @deprecated use `goog.LOCALE`
|
||||
*/
|
||||
goog.getLocale = function() {
|
||||
return goog.LOCALE;
|
||||
@@ -917,14 +917,6 @@ goog.global.CLOSURE_NO_DEPS;
|
||||
goog.global.CLOSURE_IMPORT_SCRIPT;
|
||||
|
||||
|
||||
/**
|
||||
* Null function used for default values of callbacks, etc.
|
||||
* @return {void} Nothing.
|
||||
* @deprecated use '()=>{}' or 'function(){}' instead.
|
||||
*/
|
||||
goog.nullFunction = function() {};
|
||||
|
||||
|
||||
/**
|
||||
* When defining a class Foo with an abstract method bar(), you can do:
|
||||
* Foo.prototype.bar = goog.abstractMethod
|
||||
@@ -1567,34 +1559,6 @@ goog.partial = function(fn, var_args) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Copies all the members of a source object to a target object. This method
|
||||
* does not work on all browsers for all objects that contain keys such as
|
||||
* toString or hasOwnProperty. Use goog.object.extend for this purpose.
|
||||
*
|
||||
* NOTE: Some have advocated for the use of goog.mixin to setup classes
|
||||
* with multiple inheritence (traits, mixins, etc). However, as it simply
|
||||
* uses "for in", this is not compatible with ES6 classes whose methods are
|
||||
* non-enumerable. Changing this, would break cases where non-enumerable
|
||||
* properties are not expected.
|
||||
*
|
||||
* @param {Object} target Target.
|
||||
* @param {Object} source Source.
|
||||
* @deprecated Prefer Object.assign
|
||||
*/
|
||||
goog.mixin = function(target, source) {
|
||||
for (var x in source) {
|
||||
target[x] = source[x];
|
||||
}
|
||||
|
||||
// For IE7 or lower, the for-in-loop does not contain any properties that are
|
||||
// not enumerable on the prototype object (for example, isPrototypeOf from
|
||||
// Object.prototype) but also it will not include 'replace' on objects that
|
||||
// extend String and change 'replace' (not that it is common for anyone to
|
||||
// extend anything except Object).
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} An integer value representing the number of milliseconds
|
||||
* between midnight, January 1, 1970 and the current time.
|
||||
@@ -1773,6 +1737,71 @@ if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) {
|
||||
goog.cssNameMapping_ = goog.global.CLOSURE_CSS_NAME_MAPPING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options bag type for `goog.getMsg()` third argument.
|
||||
*
|
||||
* It is important to note that these options need to be known at compile time,
|
||||
* so they must always be provided to `goog.getMsg()` as an actual object
|
||||
* literal in the function call. Otherwise, closure-compiler will report an
|
||||
* error.
|
||||
* @record
|
||||
*/
|
||||
goog.GetMsgOptions = function() {};
|
||||
|
||||
/**
|
||||
* If `true`, escape '<' in the message string to '<'.
|
||||
*
|
||||
* Used by Closure Templates where the generated code size and performance is
|
||||
* critical which is why {@link goog.html.SafeHtmlFormatter} is not used.
|
||||
* The value must be literal `true` or `false`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
goog.GetMsgOptions.prototype.html;
|
||||
|
||||
/**
|
||||
* If `true`, unescape common html entities: >, <, ', " and
|
||||
* &.
|
||||
*
|
||||
* Used for messages not in HTML context, such as with the `textContent`
|
||||
* property.
|
||||
* The value must be literal `true` or `false`.
|
||||
* @type {boolean|undefined}
|
||||
*/
|
||||
goog.GetMsgOptions.prototype.unescapeHtmlEntities;
|
||||
|
||||
/**
|
||||
* Associates placeholder names with strings showing how their values are
|
||||
* obtained.
|
||||
*
|
||||
* This field is intended for use in automatically generated JS code.
|
||||
* Human-written code should use meaningful placeholder names instead.
|
||||
*
|
||||
* closure-compiler uses this as the contents of the `<ph>` tag in the
|
||||
* XMB file it generates or defaults to `-` for historical reasons.
|
||||
*
|
||||
* Must be an object literal.
|
||||
* Ignored at runtime.
|
||||
* Keys are placeholder names.
|
||||
* Values are string literals indicating how the value is obtained.
|
||||
* Typically this is a snippet of source code.
|
||||
* @type {!Object<string, string>|undefined}
|
||||
*/
|
||||
goog.GetMsgOptions.prototype.original_code;
|
||||
|
||||
/**
|
||||
* Associates placeholder names with example values.
|
||||
*
|
||||
* closure-compiler uses this as the contents of the `<ex>` tag in the
|
||||
* XMB file it generates or defaults to `-` for historical reasons.
|
||||
*
|
||||
* Must be an object literal.
|
||||
* Ignored at runtime.
|
||||
* Keys are placeholder names.
|
||||
* Values are string literals containing example placeholder values.
|
||||
* (e.g. "George McFly" for a name placeholder)
|
||||
* @type {!Object<string, string>|undefined}
|
||||
*/
|
||||
goog.GetMsgOptions.prototype.example;
|
||||
|
||||
/**
|
||||
* Gets a localized message.
|
||||
@@ -1791,16 +1820,8 @@ if (!COMPILED && goog.global.CLOSURE_CSS_NAME_MAPPING) {
|
||||
* produce SafeHtml.
|
||||
*
|
||||
* @param {string} str Translatable string, places holders in the form {$foo}.
|
||||
* @param {Object<string, string>=} opt_values Maps place holder name to value.
|
||||
* @param {{html: (boolean|undefined),
|
||||
* unescapeHtmlEntities: (boolean|undefined)}=} opt_options Options:
|
||||
* html: Escape '<' in str to '<'. Used by Closure Templates where the
|
||||
* generated code size and performance is critical which is why {@link
|
||||
* goog.html.SafeHtmlFormatter} is not used. The value must be literal true
|
||||
* or false.
|
||||
* unescapeHtmlEntities: Unescape common html entities: >, <, ',
|
||||
* " and &. Used for messages not in HTML context, such as with
|
||||
* `textContent` property.
|
||||
* @param {!Object<string, string>=} opt_values Maps place holder name to value.
|
||||
* @param {!goog.GetMsgOptions=} opt_options see `goog.GetMsgOptions`
|
||||
* @return {string} message with placeholders filled.
|
||||
*/
|
||||
goog.getMsg = function(str, opt_values, opt_options) {
|
||||
@@ -2266,8 +2287,8 @@ if (!COMPILED && goog.DEPENDENCIES_ENABLED) {
|
||||
var src = script.src;
|
||||
var qmark = src.lastIndexOf('?');
|
||||
var l = qmark == -1 ? src.length : qmark;
|
||||
if (src.substr(l - 7, 7) == 'base.js') {
|
||||
goog.basePath = src.substr(0, l - 7);
|
||||
if (src.slice(l - 7, l) == 'base.js') {
|
||||
goog.basePath = src.slice(0, l - 7);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ export const isObject = goog.isObject;
|
||||
export const getUid = goog.getUid;
|
||||
export const hasUid = goog.hasUid;
|
||||
export const removeUid = goog.removeUid;
|
||||
export const mixin = goog.mixin;
|
||||
export const now = Date.now;
|
||||
export const globalEval = goog.globalEval;
|
||||
export const getCssName = goog.getCssName;
|
||||
@@ -65,7 +64,6 @@ export const getMsg = goog.getMsg;
|
||||
export const getMsgWithFallback = goog.getMsgWithFallback;
|
||||
export const exportSymbol = goog.exportSymbol;
|
||||
export const exportProperty = goog.exportProperty;
|
||||
export const nullFunction = goog.nullFunction;
|
||||
export const abstractMethod = goog.abstractMethod;
|
||||
export const cloneObject = goog.cloneObject;
|
||||
export const bind = goog.bind;
|
||||
|
||||
Reference in New Issue
Block a user