-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add
Blast.isServer
support to minification
- Loading branch information
Showing
2 changed files
with
8 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,21 +277,20 @@ Alchemy.setMethod(function getAllCustomHandlers(type) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.4.0 | ||
* @version 1.1.0 | ||
* @version 1.4.0 | ||
* | ||
* @param {number} level | ||
* @param {Array} args | ||
* @param {Object} options | ||
*/ | ||
Alchemy.setMethod(function printLog(level, args, options) { | ||
|
||
var type, | ||
line; | ||
|
||
if (alchemy.settings.debugging.silent) { | ||
if (Blast.isServer && this.settings.debugging.silent) { | ||
return; | ||
} | ||
|
||
let type; | ||
|
||
if (!Array.isArray(args)) { | ||
args = [args]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,7 +309,7 @@ Alchemy.setMethod(function sourcemapMiddleware(req, res, nextMiddleware) { | |
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 0.2.0 | ||
* @version 1.3.17 | ||
* @version 1.4.0 | ||
* | ||
* @param {string} path | ||
* @param {Object} options | ||
|
@@ -419,6 +419,7 @@ Alchemy.setMethod(function minifyScript(path, options, callback) { | |
if (should_minify && typeof Terser?.minify == 'function') { | ||
|
||
// Force Blast.isNode & Blast.isBrowser to be replaced later | ||
data = data.replaceAll('Blast.isServer', '__BLAST_IS_SERVER'); | ||
data = data.replaceAll('Blast.isNode', '__BLAST_IS_NODE'); | ||
data = data.replaceAll('Blast.isBrowser', '__BLAST_IS_BROWSER'); | ||
|
||
|
@@ -448,6 +449,7 @@ Alchemy.setMethod(function minifyScript(path, options, callback) { | |
// Provide it some info on global definitions | ||
global_defs : { | ||
'__BLAST_IS_NODE' : false, | ||
'__BLAST_IS_SERVER' : false, | ||
'__BLAST_IS_BROWSER' : true | ||
} | ||
}, | ||
|
@@ -485,6 +487,7 @@ Alchemy.setMethod(function minifyScript(path, options, callback) { | |
if (result.code.indexOf('__BLAST_IS_') > -1) { | ||
// Restore some instances in case these weren't removed by Terser | ||
// (Maybe because they're part of another variable or a string) | ||
result = result.code.replaceAll('__BLAST_IS_SERVER', 'Blast.isServer'); | ||
result = result.code.replaceAll('__BLAST_IS_NODE', 'Blast.isNode'); | ||
result = result.replaceAll('__BLAST_IS_BROWSER', 'Blast.isBrowser'); | ||
} else { | ||
|