Fix support ES6

This commit is contained in:
Namhyeon Go 2021-04-29 21:11:12 +09:00
parent 564d51d799
commit c126db5700
5 changed files with 14 additions and 23 deletions

View File

@ -5,7 +5,7 @@ WelsonJS - Build a Windows desktop apps with JavaScript, HTML, and CSS based on
![Structure](app/assets/img/structure.png) ![Structure](app/assets/img/structure.png)
## Specifications ## Specifications
- ES6(ECMAScript 6, Optional), ES5(ECMAScript 5), JSON compatibility - ES6(ECMAScript 6), ES5(ECMAScript 5), JSON compatibility
- [github:es-shims/es5-shim](https://github.com/es-shims/es5-shim) - [github:es-shims/es5-shim](https://github.com/es-shims/es5-shim)
- [github:paulmillr/es6-shim](https://github.com/paulmillr/es6-shim) - [github:paulmillr/es6-shim](https://github.com/paulmillr/es6-shim)
- [github:bestiejs/json3](https://github.com/bestiejs/json3) - [github:bestiejs/json3](https://github.com/bestiejs/json3)

31
app.js
View File

@ -155,13 +155,12 @@ if (typeof(CreateObject) !== "function") {
/** /**
* @FN {string} The name of the file. * @FN {string} The name of the file.
* @escapeToGlobal {bool} Specifies the scope of code to execute.
*/ */
function _require(FN, escapeToGlobal) { function require(FN) {
var cache = require.__cache = require.__cache || {}; var cache = require.__cache = require.__cache || {};
var global = require.__global;
if (FN.substr(FN.length - 3) !== '.js') FN += ".js"; if (FN.substr(FN.length - 3) !== '.js') FN += ".js";
if (cache[FN]) return cache[FN]; if (cache[FN]) return cache[FN];
if (typeof(escapeToGlobal) != "boolean") escapeToGlobal = true;
// get directory name // get directory name
var getDirName = function(path) { var getDirName = function(path) {
@ -201,13 +200,11 @@ function _require(FN, escapeToGlobal) {
} }
// make function // make function
if (!escapeToGlobal) { T = "(function(global){var module=new ModuleObject();return(function(exports,require,module,__filename,__dirname){"
T = "(function(global){var module=new ModuleObject();return(function(exports,require,module,__filename,__dirname){" + '"use strict";'
+ '"use strict";' + T
+ T + "\n\nreturn module.exports})(module.exports,global.require,module,__filename,__dirname)})(global);\n\n////@ sourceURL="
+ "\n\nreturn module.exports})(module.exports,global.require,module,__filename,__dirname)})(this);\n\n////@ sourceURL=" + FN;
+ FN;
}
// execute function // execute function
try { try {
@ -223,13 +220,7 @@ function _require(FN, escapeToGlobal) {
return cache[FN]; return cache[FN];
} }
require.__global = this;
/**
* @FN {string} The name of the file.
*/
function require(FN) {
return _require(FN, false);
}
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Load script, and call app.main() // Load script, and call app.main()
@ -303,7 +294,7 @@ var ModuleObject = function() {
//_require("app/assets/js/json2"); //_require("app/assets/js/json2");
// JSON 3 was a JSON polyfill for older JavaScript platforms // JSON 3 was a JSON polyfill for older JavaScript platforms
_require("app/assets/js/json3-3.3.2.min"); require("app/assets/js/json3-3.3.2.min");
// Babel Polyfill (7.12.1) // Babel Polyfill (7.12.1)
require("app/assets/js/babel-polyfill-7.12.1.edited"); require("app/assets/js/babel-polyfill-7.12.1.edited");
@ -317,8 +308,8 @@ var squel = require("app/assets/js/squel-basic-5.13.0.hiddentao-afa1cb5.edited")
// (Optional) // (Optional)
// ECMAScript 6 compatibility shims for legacy JS engines // ECMAScript 6 compatibility shims for legacy JS engines
//require("app/assets/js/es6-shim-0.35.6.ljharb-62dbad5"); require("app/assets/js/es6-shim-0.35.6.ljharb-62dbad5.edited");
//require("app/assets/js/es6-sham.0.35.6.ljharb-62dbad5"); require("app/assets/js/es6-sham.0.35.6.ljharb-62dbad5");
// Dive into entrypoint // Dive into entrypoint
function main() { function main() {

View File

@ -69,7 +69,7 @@
var _some = Function.call.bind(Array.prototype.some); var _some = Function.call.bind(Array.prototype.some);
var defineProperty = function (object, name, value, force) { var defineProperty = function (object, name, value, force) {
if (!force && name in object) { return; } if (!object || (!force && name in object)) { return; }
if (supportsDescriptors) { if (supportsDescriptors) {
Object.defineProperty(object, name, { Object.defineProperty(object, name, {
configurable: true, configurable: true,

View File

@ -198,7 +198,7 @@ exports.start = function(callback) {
// load jQuery and cross browsing libraries // load jQuery and cross browsing libraries
if (IEVersion == 8) { if (IEVersion == 8) {
exports.addScript("app/assets/css/jquery/webreflection-ie8-0.8.1.min.js"); exports.addScript("app/assets/css/jquery/ie8-0.8.1.min.js");
} }
exports.addScript("app/assets/js/html5shiv-printshiv-3.7.3.min.js"); exports.addScript("app/assets/js/html5shiv-printshiv-3.7.3.min.js");
if (IEVersion < 9) { if (IEVersion < 9) {