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, 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..194c3dcd --- /dev/null +++ b/lib/deps/underscore-plus.js @@ -0,0 +1,22 @@ +const regexEscape = /[-/\\^$*+?.()|[\]{}]/g +export function escapeRegExp (string) { + if (string) { + 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(regexDaherize, 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' 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": [