[ci] format
This commit is contained in:
parent
f359d77b18
commit
56d04e4100
2 changed files with 35 additions and 28 deletions
|
@ -112,7 +112,7 @@ function urlId(url: string) {
|
||||||
|
|
||||||
function getDepsFromEntry(entry: ModuleNode) {
|
function getDepsFromEntry(entry: ModuleNode) {
|
||||||
let deps = entry.ssrTransformResult?.deps ?? [];
|
let deps = entry.ssrTransformResult?.deps ?? [];
|
||||||
if(entry.ssrTransformResult?.dynamicDeps) {
|
if (entry.ssrTransformResult?.dynamicDeps) {
|
||||||
return deps.concat(entry.ssrTransformResult.dynamicDeps);
|
return deps.concat(entry.ssrTransformResult.dynamicDeps);
|
||||||
}
|
}
|
||||||
return deps;
|
return deps;
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
import {
|
import { getStylesForURL } from '../../../dist/core/render/dev/css.js';
|
||||||
getStylesForURL
|
|
||||||
} from '../../../dist/core/render/dev/css.js';
|
|
||||||
import { viteID } from '../../../dist/core/util.js';
|
import { viteID } from '../../../dist/core/util.js';
|
||||||
|
|
||||||
const root = new URL('../../fixtures/alias/', import.meta.url);
|
const root = new URL('../../fixtures/alias/', import.meta.url);
|
||||||
|
|
||||||
class TestLoader {
|
class TestLoader {
|
||||||
constructor(modules) {
|
constructor(modules) {
|
||||||
this.modules = new Map(modules.map(m => [m.id, m]))
|
this.modules = new Map(modules.map((m) => [m.id, m]));
|
||||||
}
|
}
|
||||||
getModuleById(id) {
|
getModuleById(id) {
|
||||||
return this.modules.get(id);
|
return this.modules.get(id);
|
||||||
|
@ -28,36 +26,45 @@ describe('Crawling graph for CSS', () => {
|
||||||
loader = new TestLoader([
|
loader = new TestLoader([
|
||||||
{
|
{
|
||||||
id: indexId,
|
id: indexId,
|
||||||
importedModules: [{
|
importedModules: [
|
||||||
id: aboutId,
|
{
|
||||||
url: aboutId,
|
id: aboutId,
|
||||||
}, {
|
url: aboutId,
|
||||||
id: indexId + '?astro&style.css',
|
},
|
||||||
url: indexId + '?astro&style.css',
|
{
|
||||||
ssrModule: {}
|
id: indexId + '?astro&style.css',
|
||||||
}],
|
url: indexId + '?astro&style.css',
|
||||||
|
ssrModule: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
ssrTransformResult: {
|
ssrTransformResult: {
|
||||||
deps: [indexId + '?astro&style.css']
|
deps: [indexId + '?astro&style.css'],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: aboutId,
|
id: aboutId,
|
||||||
importedModules: [{
|
importedModules: [
|
||||||
id: aboutId + '?astro&style.css',
|
{
|
||||||
url: aboutId + '?astro&style.css',
|
id: aboutId + '?astro&style.css',
|
||||||
ssrModule: {}
|
url: aboutId + '?astro&style.css',
|
||||||
}],
|
ssrModule: {},
|
||||||
|
},
|
||||||
|
],
|
||||||
ssrTransformResult: {
|
ssrTransformResult: {
|
||||||
deps: [aboutId + '?astro&style.css']
|
deps: [aboutId + '?astro&style.css'],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
})
|
});
|
||||||
|
|
||||||
it('importedModules is checked against the child\'s importers', async () => {
|
it("importedModules is checked against the child's importers", async () => {
|
||||||
// In dev mode, HMR modules tracked are added to importedModules. We use `importers`
|
// In dev mode, HMR modules tracked are added to importedModules. We use `importers`
|
||||||
// to verify that they are true importers.
|
// to verify that they are true importers.
|
||||||
const res = await getStylesForURL(new URL('./src/pages/index.astro', root), loader, 'development')
|
const res = await getStylesForURL(
|
||||||
|
new URL('./src/pages/index.astro', root),
|
||||||
|
loader,
|
||||||
|
'development'
|
||||||
|
);
|
||||||
expect(res.urls.size).to.equal(1);
|
expect(res.urls.size).to.equal(1);
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
Loading…
Reference in a new issue