nfroidure / svgicons2svgfont

Concatenate SVG icons and ouput an SVG font
http://nfroidure.github.io/svgiconfont/
MIT License
337 stars 71 forks source link

Remove "array.prototype.flatmap" #130

Closed fabiospampinato closed 3 years ago

fabiospampinato commented 3 years ago

Issue

I'm a gentledev i:

Expected behavior

I'd expect the dependency tree of this library to be reasonably shallow, but the required array.prototype.flatmap dependency adds 50+ lines to it.

├─┬ svgicons2svgfont@9.2.0
   ─┬ array.prototype.flatmap@1.2.4
    ├─┬ call-bind@1.0.2
    │ ├── function-bind@1.1.1 deduped
    │ └── get-intrinsic@1.1.1 deduped
    ├─┬ define-properties@1.1.3
    │ └── object-keys@1.1.1 deduped
    ├─┬ es-abstract@1.18.0
    │ ├── call-bind@1.0.2 deduped
    │ ├─┬ es-to-primitive@1.2.1
    │ │ ├── is-callable@1.1.5
    │ │ ├── is-date-object@1.0.2
    │ │ └─┬ is-symbol@1.0.3
    │ │   └── has-symbols@1.0.1 deduped
    │ ├── function-bind@1.1.1 deduped
    │ ├─┬ get-intrinsic@1.1.1
    │ │ ├── function-bind@1.1.1 deduped
    │ │ ├── has@1.0.3 deduped
    │ │ └── has-symbols@1.0.1
    │ ├─┬ has@1.0.3
    │ │ └── function-bind@1.1.1 deduped
    │ ├── has-symbols@1.0.2
    │ ├── is-callable@1.2.3
    │ ├── is-negative-zero@2.0.1
    │ ├─┬ is-regex@1.1.3
    │ │ ├── call-bind@1.0.2 deduped
    │ │ └── has-symbols@1.0.2 deduped
    │ ├── is-string@1.0.6
    │ ├── object-inspect@1.10.3
    │ ├── object-keys@1.1.1
    │ ├─┬ object.assign@4.1.2
    │ │ ├── call-bind@1.0.2 deduped
    │ │ ├── define-properties@1.1.3 deduped
    │ │ ├── has-symbols@1.0.2 deduped
    │ │ └── object-keys@1.1.1 deduped
    │ ├─┬ string.prototype.trimend@1.0.4
    │ │ ├── call-bind@1.0.2 deduped
    │ │ └── define-properties@1.1.3 deduped
    │ ├─┬ string.prototype.trimstart@1.0.4
    │ │ ├── call-bind@1.0.2 deduped
    │ │ └── define-properties@1.1.3 deduped
    │ └─┬ unbox-primitive@1.0.1
    │   ├── function-bind@1.1.1 deduped
    │   ├── has-bigints@1.0.1
    │   ├── has-symbols@1.0.2
    │   └─┬ which-boxed-primitive@1.0.2
    │     ├── is-bigint@1.0.2
    │     ├─┬ is-boolean-object@1.1.1
    │     │ └── call-bind@1.0.2 deduped
    │     ├── is-number-object@1.0.5
    │     ├── is-string@1.0.6 deduped
    │     └── is-symbol@1.0.3 deduped
    └── function-bind@1.1.1

Steps to reproduce the behavior

Interestingly I don't see that dependency listed in package.json here, but it's listed in my local package.json after installation, I'm guessing maybe that's actually a dependency of some other thing you are importing, or something introduced by your build system.

I'd be useful if you could make sure that dependency doesn't get included, that kind of functionality can be hard-coded easily rather than importing it from a library like core-js, or wherever that comes from, that kind of import the world for every little thing.

nfroidure commented 3 years ago

I agree but won't have time to, feel free to PR this.

pioug commented 3 years ago

Fixed in https://github.com/nfroidure/svgicons2svgfont/releases/tag/v10.0.0. A polyfill was needed to not break the previous test matrix https://github.com/nfroidure/svgicons2svgfont/pull/126.

fabiospampinato commented 3 years ago

@pioug That's not really fixed as of v10, I'm getting the following dependency tree:

├─┬ svgicons2svgfont@10.0.0
│ ├─┬ string.fromcodepoint@1.0.0
│ │ ├─┬ define-properties@1.1.3
│ │ │ └── object-keys@1.1.1
│ │ └─┬ es-abstract@1.18.0
│ │   ├─┬ call-bind@1.0.2
│ │   │ ├── function-bind@1.1.1 deduped
│ │   │ └── get-intrinsic@1.1.1 deduped
│ │   ├─┬ es-to-primitive@1.2.1
│ │   │ ├── is-callable@1.1.5
│ │   │ ├── is-date-object@1.0.2
│ │   │ └─┬ is-symbol@1.0.3
│ │   │   └── has-symbols@1.0.1 deduped
│ │   ├── function-bind@1.1.1
│ │   ├─┬ get-intrinsic@1.1.1
│ │   │ ├── function-bind@1.1.1 deduped
│ │   │ ├── has@1.0.3 deduped
│ │   │ └── has-symbols@1.0.1
│ │   ├─┬ has@1.0.3
│ │   │ └── function-bind@1.1.1 deduped
│ │   ├── has-symbols@1.0.2
│ │   ├── is-callable@1.2.3
│ │   ├── is-negative-zero@2.0.1
│ │   ├─┬ is-regex@1.1.3
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ └── has-symbols@1.0.2 deduped
│ │   ├── is-string@1.0.6
│ │   ├── object-inspect@1.10.3
│ │   ├── object-keys@1.1.1 deduped
│ │   ├─┬ object.assign@4.1.2
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ ├── define-properties@1.1.3 deduped
│ │   │ ├── has-symbols@1.0.2 deduped
│ │   │ └── object-keys@1.1.1 deduped
│ │   ├─┬ string.prototype.trimend@1.0.4
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ └── define-properties@1.1.3 deduped
│ │   ├─┬ string.prototype.trimstart@1.0.4
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ └── define-properties@1.1.3 deduped
│ │   └─┬ unbox-primitive@1.0.1
│ │     ├── function-bind@1.1.1 deduped
│ │     ├── has-bigints@1.0.1
│ │     ├── has-symbols@1.0.2
│ │     └─┬ which-boxed-primitive@1.0.2
│ │       ├── is-bigint@1.0.2
│ │       ├─┬ is-boolean-object@1.1.1
│ │       │ └── call-bind@1.0.2 deduped
│ │       ├── is-number-object@1.0.5
│ │       ├── is-string@1.0.6 deduped
│ │       └── is-symbol@1.0.3 deduped
│ ├─┬ string.prototype.codepointat@1.0.0
│ │ └─┬ es-abstract@1.18.0
│ │   ├── call-bind@1.0.2 deduped
│ │   ├── es-to-primitive@1.2.1 deduped
│ │   ├── function-bind@1.1.1 deduped
│ │   ├── get-intrinsic@1.1.1 deduped
│ │   ├── has@1.0.3 deduped
│ │   ├── has-symbols@1.0.2
│ │   ├── is-callable@1.2.3
│ │   ├── is-negative-zero@2.0.1 deduped
│ │   ├─┬ is-regex@1.1.3
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ └── has-symbols@1.0.2 deduped
│ │   ├── is-string@1.0.6 deduped
│ │   ├── object-inspect@1.10.3
│ │   ├── object-keys@1.1.1 deduped
│ │   ├─┬ object.assign@4.1.2
│ │   │ ├── call-bind@1.0.2 deduped
│ │   │ ├── define-properties@1.1.3 deduped
│ │   │ ├── has-symbols@1.0.2 deduped
│ │   │ └── object-keys@1.1.1 deduped
│ │   ├── string.prototype.trimend@1.0.4 deduped
│ │   ├── string.prototype.trimstart@1.0.4 deduped
│ │   └── unbox-primitive@1.0.1 deduped

Those useless polyfills should be removed too to really fix this, basically whatever polyfill is imported causes all the junk to be imported too.

pioug commented 3 years ago

@fabiospampinato I see. At least array.prototype.flatmap is removed. Anyway, feel free to make PR.

pioug commented 3 years ago

Removed string.fromcodepoint and string.prototype.codepointat in v10.0.1

fabiospampinato commented 3 years ago

Sweet, now the dependency tree is much smaller, thank you for that!

XhmikosR commented 2 years ago

This is further improved by #142 and #145 (the latter is yet to be released).