-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move to esm * update test workflow * add esm config tests * cleanup fixtures * some more cleanup * fix formatting * fix test names
- Loading branch information
Showing
101 changed files
with
1,384 additions
and
2,047 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,62 @@ | ||
let SizeLimitError = require('size-limit/size-limit-error') | ||
let { spawn } = require('child_process') | ||
let { join } = require('path') | ||
let rm = require('size-limit/rm') | ||
import { spawn } from 'child_process' | ||
import { join } from 'path' | ||
import rm from 'size-limit/rm' | ||
import { SizeLimitError } from 'size-limit/size-limit-error' | ||
|
||
let self = { | ||
async all10(config) { | ||
let stderr = '' | ||
let cmd = spawn( | ||
process.platform === 'win32' ? 'npx.cmd' : 'npx', | ||
['-y', '-q', 'dual-publish', '--check'], | ||
{ cwd: config.cwd } | ||
) | ||
cmd.stderr.on('data', data => { | ||
stderr += data.toString().replace(/^ ERROR {2}/, '') | ||
}) | ||
await new Promise((resolve, reject) => { | ||
cmd.on('close', code => { | ||
if (code !== 0 || stderr) { | ||
reject(new SizeLimitError('cmdError', 'dual-publish', stderr)) | ||
} else { | ||
resolve() | ||
} | ||
}) | ||
cmd.on('error', reject) | ||
}) | ||
for (let check of config.checks) { | ||
check.files = check.files.map(i => { | ||
return join( | ||
config.cwd, | ||
'dual-publish-tmp', | ||
i.slice(config.cwd.length + 1) | ||
) | ||
export default [ | ||
{ | ||
async all10(config) { | ||
let stderr = '' | ||
let cmd = spawn( | ||
process.platform === 'win32' ? 'npx.cmd' : 'npx', | ||
['-y', '-q', 'dual-publish', '--check'], | ||
{ cwd: config.cwd } | ||
) | ||
cmd.stderr.on('data', data => { | ||
stderr += data.toString().replace(/^ ERROR {2}/, '') | ||
}) | ||
if (check.import) { | ||
let imports = {} | ||
for (let i in check.import) { | ||
if (!i.includes('node_modules')) { | ||
let changed = join( | ||
config.cwd, | ||
'dual-publish-tmp', | ||
i.slice(config.cwd.length + 1) | ||
) | ||
imports[changed] = check.import[i] | ||
await new Promise((resolve, reject) => { | ||
cmd.on('close', code => { | ||
if (code !== 0 || stderr) { | ||
reject(new SizeLimitError('cmdError', 'dual-publish', stderr)) | ||
} else { | ||
imports[i] = check.import[i] | ||
resolve() | ||
} | ||
}) | ||
cmd.on('error', reject) | ||
}) | ||
for (let check of config.checks) { | ||
check.files = check.files.map(i => { | ||
return join( | ||
config.cwd, | ||
'dual-publish-tmp', | ||
i.slice(config.cwd.length + 1) | ||
) | ||
}) | ||
if (check.import) { | ||
let imports = {} | ||
for (let i in check.import) { | ||
if (!i.includes('node_modules')) { | ||
let changed = join( | ||
config.cwd, | ||
'dual-publish-tmp', | ||
i.slice(config.cwd.length + 1) | ||
) | ||
imports[changed] = check.import[i] | ||
} else { | ||
imports[i] = check.import[i] | ||
} | ||
} | ||
check.import = imports | ||
} | ||
check.import = imports | ||
} | ||
} | ||
}, | ||
|
||
async finally(config) { | ||
await rm(join(config.cwd, 'dual-publish-tmp')) | ||
}, | ||
name: '@size-limit/dual-publish', | ||
}, | ||
|
||
wait10: 'Compiling files to ESM' | ||
} | ||
async finally(config) { | ||
await rm(join(config.cwd, 'dual-publish-tmp')) | ||
}, | ||
name: '@size-limit/dual-publish', | ||
|
||
module.exports = [self] | ||
wait10: 'Compiling files to ESM' | ||
} | ||
] |
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
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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
let { visualizer } = require('esbuild-visualizer') | ||
let { join } = require('path') | ||
let { writeFileSync } = require('fs') | ||
let open = require('open') | ||
import { visualizer } from 'esbuild-visualizer' | ||
import { writeFileSync } from 'fs' | ||
import open from 'open' | ||
import { join } from 'path' | ||
|
||
let { getReportName } = require('./report') | ||
import { getReportName } from './report' | ||
|
||
let self = { | ||
async finally(config, check) { | ||
let {esbuildVisualizerFile} = check | ||
export default [ | ||
{ | ||
async finally(config, check) { | ||
let { esbuildVisualizerFile } = check | ||
|
||
if (esbuildVisualizerFile) { | ||
await open(esbuildVisualizerFile) | ||
} | ||
}, | ||
if (esbuildVisualizerFile) { | ||
await open(esbuildVisualizerFile) | ||
} | ||
}, | ||
|
||
name: '@size-limit/esbuild-why', | ||
async step81(config, check) { | ||
if (config.why && check.esbuildMetafile) { | ||
let result = await visualizer(check.esbuildMetafile) | ||
let file = join(config.saveBundle ?? '', getReportName(config, check)) | ||
check.esbuildVisualizerFile = file; | ||
writeFileSync(file, result) | ||
name: '@size-limit/esbuild-why', | ||
async step81(config, check) { | ||
if (config.why && check.esbuildMetafile) { | ||
let result = await visualizer(check.esbuildMetafile) | ||
let file = join(config.saveBundle ?? '', getReportName(config, check)) | ||
check.esbuildVisualizerFile = file | ||
writeFileSync(file, result) | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = [self] | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
let { isValidFilename } = require('./valid-filename') | ||
import { isValidFilename } from './valid-filename' | ||
|
||
module.exports = { | ||
getReportName(config, check) { | ||
if (config.checks.length === 1) return `esbuild-why.html` | ||
if (isValidFilename(check.name)) return `esbuild-why-${check.name}.html` | ||
let index = config.checks.findIndex(c => c.name === check.name) | ||
return `esbuild-why-${index + 1}.html` | ||
} | ||
export function getReportName(config, check) { | ||
if (config.checks.length === 1) return `esbuild-why.html` | ||
if (isValidFilename(check.name)) return `esbuild-why-${check.name}.html` | ||
let index = config.checks.findIndex(c => c.name === check.name) | ||
return `esbuild-why-${index + 1}.html` | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
module.exports = { | ||
isValidFilename(string) { | ||
if (!string || string.length > 255 || string === '.' || string === '..') { | ||
return false | ||
} | ||
return ( | ||
!/[<>:"/\\|?*\u0000-\u001F]/g.test(string) && | ||
!/^(con|prn|aux|nul|com\d|lpt\d)$/i.test(string) | ||
) | ||
export function isValidFilename(string) { | ||
if (!string || string.length > 255 || string === '.' || string === '..') { | ||
return false | ||
} | ||
return ( | ||
!/[<>:"/\\|?*\u0000-\u001F]/g.test(string) && | ||
!/^(con|prn|aux|nul|com\d|lpt\d)$/i.test(string) | ||
) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = function convertConfig(config) { | ||
export function convertConfig(config) { | ||
config.metafile = true | ||
} |
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
Oops, something went wrong.