Skip to content

Commit

Permalink
perf: use @jridgewell/sourcemap-codec
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 2, 2022
1 parent 69b13c7 commit e68f3e0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
22 changes: 11 additions & 11 deletions benchmark/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ console.log(`node ${process.version}\n`);

function runWithInstance(name, inputs, func, setup) {
const ss = [];
return new Benchmark(
new Benchmark(
name,
{
setup: () => {
Expand Down Expand Up @@ -39,17 +39,17 @@ async function bench() {
)
);

new Benchmark('construct', {
fn: () => {
for (const input of inputs) {
new MagicString(input);
}
new Benchmark('construct', {
fn: () => {
for (const input of inputs) {
new MagicString(input);
}
}).on('complete', (event) => {
console.log(String(event.target));
}).on('error', (event) => {
console.error(event.target.error);
}).run()
}
}).on('complete', (event) => {
console.log(String(event.target));
}).on('error', (event) => {
console.error(event.target.error);
}).run();

runWithInstance('append', inputs, s => {
s.append(';"append";');
Expand Down
18 changes: 15 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
"bench": "npm run build && node benchmark/index.mjs",
"watch": "rollup -cw"
},
"dependencies": {
"sourcemap-codec": "^1.4.8"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-replace": "^4.0.0",
Expand All @@ -60,5 +57,8 @@
},
"engines": {
"node": ">=12"
},
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.13"
}
}
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default [
/* esm */
{
input: 'src/index.js',
external: ['sourcemap-codec'],
external: ['@jridgewell/sourcemap-codec'],
plugins,
output: {
file: 'dist/magic-string.es.mjs',
Expand All @@ -23,7 +23,7 @@ export default [
/* cjs */
{
input: 'src/index-legacy.js',
external: ['sourcemap-codec'],
external: ['@jridgewell/sourcemap-codec'],
plugins,
output: {
file: 'dist/magic-string.cjs.js',
Expand Down
2 changes: 1 addition & 1 deletion src/SourceMap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encode } from 'sourcemap-codec';
import { encode } from '@jridgewell/sourcemap-codec';

let btoa = () => {
throw new Error('Unsupported environment: `window.btoa` or `Buffer` should be supported.');
Expand Down

0 comments on commit e68f3e0

Please sign in to comment.