-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rely on local Terser for minify, disable conditionals
- Loading branch information
Michael Bullington
committed
Sep 5, 2019
1 parent
df96942
commit bd41b07
Showing
8 changed files
with
95 additions
and
35 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 |
---|---|---|
|
@@ -14,3 +14,5 @@ packages | |
|
||
# Include when developing application packages. | ||
pubspec.lock | ||
|
||
node_modules |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"terser": "^4.2.1" | ||
}, | ||
"scripts": { | ||
"minify": "node tool/minify.js" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const Terser = require("terser"); | ||
|
||
const LIB_DIR = path.join(__dirname, "..", "lib"); | ||
|
||
const PATH = path.join(LIB_DIR, "preamble.js"); | ||
|
||
const MIN_PATH = path.join(LIB_DIR, "preamble.min.js"); | ||
const DART_PATH = path.join(LIB_DIR, "preamble.dart"); | ||
|
||
const preamble = fs.readFileSync(PATH).toString(); | ||
|
||
const { code: minified, error } = Terser.minify(preamble, { | ||
// Needed for Webpack require override. | ||
compress: { | ||
conditionals: false | ||
} | ||
}); | ||
|
||
if (error) { | ||
throw error; | ||
} | ||
|
||
fs.writeFileSync(MIN_PATH, minified); | ||
|
||
fs.writeFileSync(DART_PATH, `library node_preamble; | ||
final _minified = r\"""${minified}\"""; | ||
final _normal = r\""" | ||
${preamble}\"""; | ||
/// Returns the text of the preamble. | ||
/// | ||
/// If [minified] is true, returns the minified version rather than the | ||
/// human-readable version. | ||
String getPreamble({bool minified: false, List<String> additionalGlobals: const []}) => | ||
(minified ? _minified : _normal) + | ||
(additionalGlobals == null ? "" : | ||
additionalGlobals.map((global) => "self.\$global=\$global;").join()); | ||
`); |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
buffer-from@^1.0.0: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" | ||
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== | ||
|
||
commander@^2.20.0: | ||
version "2.20.0" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" | ||
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== | ||
|
||
source-map-support@~0.5.12: | ||
version "0.5.13" | ||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" | ||
integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w== | ||
dependencies: | ||
buffer-from "^1.0.0" | ||
source-map "^0.6.0" | ||
|
||
source-map@^0.6.0, source-map@~0.6.1: | ||
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" | ||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== | ||
|
||
terser@^4.2.1: | ||
version "4.2.1" | ||
resolved "https://registry.yarnpkg.com/terser/-/terser-4.2.1.tgz#1052cfe17576c66e7bc70fcc7119f22b155bdac1" | ||
integrity sha512-cGbc5utAcX4a9+2GGVX4DsenG6v0x3glnDi5hx8816X1McEAwPlPgRtXPJzSBsbpILxZ8MQMT0KvArLuE0HP5A== | ||
dependencies: | ||
commander "^2.20.0" | ||
source-map "~0.6.1" | ||
source-map-support "~0.5.12" |