Skip to content

Commit

Permalink
fix: Add flatMap() fallback; fixes #26 (#27)
Browse files Browse the repository at this point in the history
fix: Add flatMap() fallback; fixes #26
  • Loading branch information
danburzo committed Aug 18, 2020
1 parent 81e3d82 commit 46b616b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [14.x]
node-version: [10.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 3 additions & 1 deletion src/minify-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const { RawSource, SourceMapSource } = require('webpack-sources')
const isJsFile = /\.js$/i
const pluginName = 'esbuild-minify'

const flatMap = (arr, cb) => arr.flatMap ? arr.flatMap(cb) : [].concat(...arr.map(cb))

class ESBuildMinifyPlugin {
constructor(options) {
this.options = { ...options }
Expand Down Expand Up @@ -39,7 +41,7 @@ class ESBuildMinifyPlugin {
compilation.hooks.optimizeChunkAssets.tapPromise(
pluginName,
async (chunks) => {
const transforms = chunks.flatMap((chunk) => {
const transforms = flatMap(chunks, (chunk) => {
return chunk.files
.filter((file) => isJsFile.test(file))
.map(async (file) => {
Expand Down

0 comments on commit 46b616b

Please sign in to comment.