Skip to content

Commit 847502c

Browse files
authoredDec 3, 2022
Merge pull request #215 from sapphi-red/perf/encode-decode
perf: use `@jridgewell/sourcemap-codec`
2 parents 634d205 + e68f3e0 commit 847502c

File tree

5 files changed

+32
-20
lines changed

5 files changed

+32
-20
lines changed
 

‎benchmark/index.mjs

+11-11
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

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+3-3
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": "^14.1.0",
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

+2-2
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

+1-1
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
function getBtoa () {
44
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {

0 commit comments

Comments
 (0)
Please sign in to comment.