-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`import.meta` is defined. `new URL('./package.json', import.meta.url)` works now if the file is in the `--assets` folder (defaults to process.cwd())
- Loading branch information
1 parent
f2f5fbb
commit e7bde86
Showing
13 changed files
with
140 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
const path = require('path') | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
export default { | ||
buildSWConfig: { | ||
inject: [path.join(__dirname, 'sw-globals.js')], | ||
}, | ||
afterTests: () => { | ||
console.log('AFTER') | ||
} | ||
}, | ||
} |
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,13 @@ | ||
const path = require('path') | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
const __dirname = path.dirname(fileURLToPath(import.meta.url)) | ||
|
||
export default Promise.resolve({ | ||
buildSWConfig: { | ||
inject: [path.join(__dirname, 'sw-globals.js')], | ||
}, | ||
afterTests: () => { | ||
console.log('AFTER') | ||
} | ||
}, | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Bench } from 'tinybench' | ||
|
||
const bench = new Bench({ time: 100 }) | ||
|
||
bench | ||
.add('switch 1', () => { | ||
let a = 1 | ||
let b = 2 | ||
const c = a | ||
a = b | ||
b = c | ||
}) | ||
.add('switch 2', () => { | ||
let a = 1 | ||
let b = 10 | ||
a = b + a | ||
b = a - b | ||
a = b - a | ||
}) | ||
|
||
await bench.run() | ||
|
||
console.table( | ||
bench.tasks.map(({ name, result }) => ({ | ||
'Task Name': name, | ||
'Average Time (ps)': result?.mean * 1000, | ||
'Variance (ps)': result?.variance * 1000, | ||
})) | ||
) | ||
|
||
// Output: | ||
// ┌─────────┬────────────┬────────────────────┬────────────────────┐ | ||
// │ (index) │ Task Name │ Average Time (ps) │ Variance (ps) │ | ||
// ├─────────┼────────────┼────────────────────┼────────────────────┤ | ||
// │ 0 │ 'switch 1' │ 1.8458325710527104 │ 1.2113875253341617 │ | ||
// │ 1 │ 'switch 2' │ 1.8746935152109603 │ 1.2254725890767446 │ | ||
// └─────────┴────────────┴────────────────────┴────────────────────┘ |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Bench } from 'tinybench' | ||
|
||
const bench = new Bench({ time: 100 }) | ||
|
||
bench | ||
.add('switch 1', () => { | ||
let a = 1 | ||
let b = 2 | ||
const c = a | ||
a = b | ||
b = c | ||
}) | ||
.add('switch 2', () => { | ||
let a = 1 | ||
let b = 10 | ||
a = b + a | ||
b = a - b | ||
a = b - a | ||
}) | ||
|
||
await bench.run() | ||
|
||
console.table( | ||
bench.tasks.map(({ name, result }) => ({ | ||
'Task Name': name, | ||
'Average Time (ps)': result?.mean * 1000, | ||
'Variance (ps)': result?.variance * 1000, | ||
})) | ||
) | ||
|
||
// Output: | ||
// ┌─────────┬────────────┬────────────────────┬────────────────────┐ | ||
// │ (index) │ Task Name │ Average Time (ps) │ Variance (ps) │ | ||
// ├─────────┼────────────┼────────────────────┼────────────────────┤ | ||
// │ 0 │ 'switch 1' │ 1.8458325710527104 │ 1.2113875253341617 │ | ||
// │ 1 │ 'switch 2' │ 1.8746935152109603 │ 1.2254725890767446 │ | ||
// └─────────┴────────────┴────────────────────┴────────────────────┘ |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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