Skip to content

Commit e68f3e0

Browse files
committed
perf: use @jridgewell/sourcemap-codec
1 parent 69b13c7 commit e68f3e0

5 files changed

Lines changed: 32 additions & 20 deletions

File tree

benchmark/index.mjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ console.log(`node ${process.version}\n`);
88

99
function runWithInstance(name, inputs, func, setup) {
1010
const ss = [];
11-
return new Benchmark(
11+
new Benchmark(
1212
name,
1313
{
1414
setup: () => {
@@ -39,17 +39,17 @@ async function bench() {
3939
)
4040
);
4141

42-
new Benchmark('construct', {
43-
fn: () => {
44-
for (const input of inputs) {
45-
new MagicString(input);
46-
}
42+
new Benchmark('construct', {
43+
fn: () => {
44+
for (const input of inputs) {
45+
new MagicString(input);
4746
}
48-
}).on('complete', (event) => {
49-
console.log(String(event.target));
50-
}).on('error', (event) => {
51-
console.error(event.target.error);
52-
}).run()
47+
}
48+
}).on('complete', (event) => {
49+
console.log(String(event.target));
50+
}).on('error', (event) => {
51+
console.error(event.target.error);
52+
}).run();
5353

5454
runWithInstance('append', inputs, s => {
5555
s.append(';"append";');

package-lock.json

Lines changed: 15 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
"bench": "npm run build && node benchmark/index.mjs",
4343
"watch": "rollup -cw"
4444
},
45-
"dependencies": {
46-
"sourcemap-codec": "^1.4.8"
47-
},
4845
"devDependencies": {
4946
"@rollup/plugin-node-resolve": "^13.1.3",
5047
"@rollup/plugin-replace": "^4.0.0",
@@ -60,5 +57,8 @@
6057
},
6158
"engines": {
6259
"node": ">=12"
60+
},
61+
"dependencies": {
62+
"@jridgewell/sourcemap-codec": "^1.4.13"
6363
}
6464
}

rollup.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default [
1010
/* esm */
1111
{
1212
input: 'src/index.js',
13-
external: ['sourcemap-codec'],
13+
external: ['@jridgewell/sourcemap-codec'],
1414
plugins,
1515
output: {
1616
file: 'dist/magic-string.es.mjs',
@@ -23,7 +23,7 @@ export default [
2323
/* cjs */
2424
{
2525
input: 'src/index-legacy.js',
26-
external: ['sourcemap-codec'],
26+
external: ['@jridgewell/sourcemap-codec'],
2727
plugins,
2828
output: {
2929
file: 'dist/magic-string.cjs.js',

src/SourceMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { encode } from 'sourcemap-codec';
1+
import { encode } from '@jridgewell/sourcemap-codec';
22

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

0 commit comments

Comments
 (0)