From 009986300506416aa30b3f1c9a326f6160cceb19 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:00:26 -0600 Subject: [PATCH 1/6] fix: turn-off toplevel optimizations https://github.com/terser/terser/issues/907 --- .terserrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.terserrc.js b/.terserrc.js index 992fd111..27b4073b 100644 --- a/.terserrc.js +++ b/.terserrc.js @@ -10,7 +10,7 @@ export default { "@atom.inSpecMode": !isTest ? "() => false" : "() => true" }, "ecma": "2018", // Change based on the target - // "toplevel": true, // controlled by Parcel + "toplevel": false, "hoist_vars": false, "hoist_funs": true, "pure_getters": true, From 2ee74b9c730e6836a8c3e00b64681a305598b6e6 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:28:49 -0600 Subject: [PATCH 2/6] fix: replace underscore-plus by custom implementation --- lib/decoration-management.js | 2 +- lib/deps/underscore-plus.js | 20 ++++++++++++++++++++ lib/minimap-plugin-generator-element.js | 2 +- lib/mixins/canvas-drawer.js | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 lib/deps/underscore-plus.js diff --git a/lib/decoration-management.js b/lib/decoration-management.js index d8fe7ff0..a4b096a5 100644 --- a/lib/decoration-management.js +++ b/lib/decoration-management.js @@ -1,7 +1,7 @@ 'use strict' import { Emitter } from 'atom' -import { escapeRegExp } from 'underscore-plus' +import { escapeRegExp } from './deps/underscore-plus' import path from 'path' import Decoration from './decoration' diff --git a/lib/deps/underscore-plus.js b/lib/deps/underscore-plus.js new file mode 100644 index 00000000..58e0e1af --- /dev/null +++ b/lib/deps/underscore-plus.js @@ -0,0 +1,20 @@ +export function escapeRegExp (string) { + if (string) { + return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + } else { + return '' + } +} + +export function dasherize (string) { + if (!string) { return '' } + + string = string[0].toLowerCase() + string.slice(1) + return string.replace(/([A-Z])|(_)/g, function (m, letter) { + if (letter) { + return '-' + letter.toLowerCase() + } else { + return '-' + } + }) +} diff --git a/lib/minimap-plugin-generator-element.js b/lib/minimap-plugin-generator-element.js index 81a3bbb5..49d190d3 100644 --- a/lib/minimap-plugin-generator-element.js +++ b/lib/minimap-plugin-generator-element.js @@ -1,6 +1,6 @@ 'use strict' -import { dasherize } from 'underscore-plus' +import { dasherize } from './deps/underscore-plus' import { getHomeDirectory, existsSync } from 'fs-plus' import path from 'path' import { BufferedProcess } from 'atom' diff --git a/lib/mixins/canvas-drawer.js b/lib/mixins/canvas-drawer.js index ee039897..8227d42a 100644 --- a/lib/mixins/canvas-drawer.js +++ b/lib/mixins/canvas-drawer.js @@ -1,6 +1,6 @@ 'use strict' -import { escapeRegExp } from 'underscore-plus' +import { escapeRegExp } from '../deps/underscore-plus' import Mixin from 'mixto' import * as Main from '../main' From 2a64ecbd76db73bf2bb2fd3571d21b8e246308dd Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:29:58 -0600 Subject: [PATCH 3/6] fix: store the regexp in a const --- lib/deps/underscore-plus.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/deps/underscore-plus.js b/lib/deps/underscore-plus.js index 58e0e1af..9a501bdc 100644 --- a/lib/deps/underscore-plus.js +++ b/lib/deps/underscore-plus.js @@ -1,16 +1,18 @@ +const regexEscape = /[-\/\\^$*+?.()|[\]{}]/g export function escapeRegExp (string) { if (string) { - return string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + return string.replace(regexEscape, '\\$&') } else { return '' } } +const regexDaherize = /([A-Z])|(_)/g export function dasherize (string) { if (!string) { return '' } string = string[0].toLowerCase() + string.slice(1) - return string.replace(/([A-Z])|(_)/g, function (m, letter) { + return string.replace(regexDaherize, function (m, letter) { if (letter) { return '-' + letter.toLowerCase() } else { From 2687541b53e6b8f6c2b466b4f37f365f9b506c86 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:30:19 -0600 Subject: [PATCH 4/6] fix: no need escape / --- lib/deps/underscore-plus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deps/underscore-plus.js b/lib/deps/underscore-plus.js index 9a501bdc..b7a14876 100644 --- a/lib/deps/underscore-plus.js +++ b/lib/deps/underscore-plus.js @@ -1,4 +1,4 @@ -const regexEscape = /[-\/\\^$*+?.()|[\]{}]/g +const regexEscape = /[-/\\^$*+?.()|[\]{}]/g export function escapeRegExp (string) { if (string) { return string.replace(regexEscape, '\\$&') From 92be9d8c538eb21dbc5ed4931c9aa47afa79ea92 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:31:41 -0600 Subject: [PATCH 5/6] fix: use string inerpolation --- lib/deps/underscore-plus.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/deps/underscore-plus.js b/lib/deps/underscore-plus.js index b7a14876..194c3dcd 100644 --- a/lib/deps/underscore-plus.js +++ b/lib/deps/underscore-plus.js @@ -11,10 +11,10 @@ const regexDaherize = /([A-Z])|(_)/g export function dasherize (string) { if (!string) { return '' } - string = string[0].toLowerCase() + string.slice(1) + string = `${string[0].toLowerCase()}${string.slice(1)}` return string.replace(regexDaherize, function (m, letter) { if (letter) { - return '-' + letter.toLowerCase() + return `-${letter.toLowerCase()}` } else { return '-' } From 07512f32aca7e30a6a3f52332f62e1241d565e1a Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Tue, 12 Jan 2021 16:32:14 -0600 Subject: [PATCH 6/6] fix: make underscore-plus a devDep --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a8efa5c9..0770a660 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ "delegato": "^1.0.0", "element-resize-detector": "^1.2.1", "fs-plus": "^3.1.1", - "mixto": "^1.0.0", - "underscore-plus": "^1.7.0" + "mixto": "^1.0.0" }, "devDependencies": { "@types/atom": "^1.40.5", @@ -74,7 +73,8 @@ "rollup": "2.36.1", "rollup-plugin-atomic": "^2.0.1", "shx": "^0.3.3", - "standard": "^16.0.3" + "standard": "^16.0.3", + "underscore-plus": "^1.7.0" }, "standard": { "globals": [