-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: use pure esm - also for json modules
- Loading branch information
1 parent
e183d8e
commit 52e9c89
Showing
26 changed files
with
98 additions
and
83 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
packages/@dicebear/collection/tests/fixtures/tree-shaking/index.js
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,4 +1,4 @@ | ||
import { createAvatar } from '@dicebear/core'; | ||
import { identicon } from '../../../lib/index.js'; | ||
import { Identicon } from '../../../lib/index.js'; | ||
|
||
document.body.innerHTML = createAvatar(identicon, { seed: 'John Doe' }); | ||
document.body.innerHTML = createAvatar(Identicon, { seed: 'John Doe' }); |
34 changes: 18 additions & 16 deletions
34
packages/@dicebear/collection/tests/tree-shaking.rollup.test.js
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,27 +1,29 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { fileURLToPath } from 'url'; | ||
import { test } from 'uvu'; | ||
import { equal, match } from 'uvu/assert'; | ||
import { rollup } from 'rollup'; | ||
import { nodeResolve } from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import json from '@rollup/plugin-json'; | ||
|
||
const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
|
||
test(`Tree shaking with rollup`, async () => { | ||
const bundle = await rollup({ | ||
input: `${__dirname}/fixtures/tree-shaking/index.js`, | ||
plugins: [nodeResolve(), commonjs()], | ||
}); | ||
describe('rollup', () => { | ||
it('Tree shaking', async () => { | ||
const bundle = await rollup({ | ||
input: `${__dirname}/fixtures/tree-shaking/index.js`, | ||
plugins: [nodeResolve(), commonjs(), json()], | ||
}); | ||
|
||
const { output } = await bundle.generate({ | ||
format: 'esm', | ||
}); | ||
const { output } = await bundle.generate({ | ||
format: 'esm', | ||
}); | ||
|
||
equal(output.length, 1); | ||
assert.strictEqual(output.length, 1); | ||
|
||
for (const module in output[0].modules) { | ||
match(module, /@dicebear\/(core|converter|identicon|collection)/); | ||
} | ||
for (const module in output[0].modules) { | ||
assert.doesNotMatch(module, /Adventurer/i); | ||
} | ||
}); | ||
}); | ||
|
||
test.run(); |
59 changes: 30 additions & 29 deletions
59
packages/@dicebear/collection/tests/tree-shaking.webpack.test.js
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,39 +1,40 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { fileURLToPath } from 'url'; | ||
import { test } from 'uvu'; | ||
import { match } from 'uvu/assert'; | ||
import webpack from 'webpack'; | ||
import { dirSync } from 'tmp'; | ||
|
||
const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
|
||
test(`Tree shaking with webpack`, async () => { | ||
const tmpDir = dirSync(); | ||
describe('webpack', () => { | ||
it('Tree shaking', async () => { | ||
const tmpDir = dirSync(); | ||
|
||
const modules = await new Promise((resolve, reject) => { | ||
webpack( | ||
{ | ||
entry: `${__dirname}/fixtures/tree-shaking/index.js`, | ||
mode: 'production', | ||
output: { | ||
path: tmpDir.name, | ||
const modules = await new Promise((resolve, reject) => { | ||
webpack( | ||
{ | ||
entry: `${__dirname}/fixtures/tree-shaking/index.js`, | ||
mode: 'production', | ||
output: { | ||
path: tmpDir.name, | ||
}, | ||
}, | ||
}, | ||
(err, stats) => { | ||
err | ||
? reject(err) | ||
: resolve( | ||
stats | ||
.toJson() | ||
.modules.filter((v) => v.usedExports) | ||
.map((v) => v.identifier), | ||
); | ||
}, | ||
); | ||
}); | ||
(err, stats) => { | ||
err | ||
? reject(err) | ||
: resolve( | ||
stats | ||
.toJson() | ||
.modules.filter((v) => v.usedExports) | ||
.map((v) => v.identifier), | ||
); | ||
}, | ||
); | ||
}); | ||
|
||
for (const module of modules) { | ||
match(module, /@dicebear\/(core|converter|identicon|collection)/); | ||
} | ||
for (const module of modules) { | ||
assert.doesNotMatch(module, /Adventurer/i); | ||
} | ||
}); | ||
}); | ||
|
||
test.run(); |
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
1 change: 0 additions & 1 deletion
1
packages/@dicebear/core/tests/fixtures/definitions/loader/initials.cjs
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/@dicebear/core/tests/fixtures/definitions/loader/minimal.cjs
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/@dicebear/core/tests/fixtures/definitions/loader/shape-face.cjs
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/@dicebear/core/tests/fixtures/definitions/styles/Initials.js
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
2 changes: 1 addition & 1 deletion
2
packages/@dicebear/core/tests/fixtures/definitions/styles/Minimal.js
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
2 changes: 1 addition & 1 deletion
2
packages/@dicebear/core/tests/fixtures/definitions/styles/ShapeFace.js
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
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