Compatiblity between hoisted scripts and tailwind integration (#4755)
* Compatiblity between hoisted scripts and tailwind integration * Adds a changeset
This commit is contained in:
parent
1bedb9427e
commit
f1efd88dde
7 changed files with 81 additions and 44 deletions
5
.changeset/spotty-ways-cry.md
Normal file
5
.changeset/spotty-ways-cry.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Upgrade to Vite 3.1
|
|
@ -138,7 +138,7 @@
|
||||||
"recast": "^0.20.5",
|
"recast": "^0.20.5",
|
||||||
"rehype": "^12.0.1",
|
"rehype": "^12.0.1",
|
||||||
"resolve": "^1.22.0",
|
"resolve": "^1.22.0",
|
||||||
"rollup": "~2.77.0",
|
"rollup": "~2.78.0",
|
||||||
"semver": "^7.3.7",
|
"semver": "^7.3.7",
|
||||||
"shiki": "^0.11.1",
|
"shiki": "^0.11.1",
|
||||||
"sirv": "^2.0.2",
|
"sirv": "^2.0.2",
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
"tsconfig-resolver": "^3.0.1",
|
"tsconfig-resolver": "^3.0.1",
|
||||||
"unist-util-visit": "^4.1.0",
|
"unist-util-visit": "^4.1.0",
|
||||||
"vfile": "^5.3.2",
|
"vfile": "^5.3.2",
|
||||||
"vite": "3.0.9",
|
"vite": "3.1.0",
|
||||||
"yargs-parser": "^21.0.1",
|
"yargs-parser": "^21.0.1",
|
||||||
"zod": "^3.17.3"
|
"zod": "^3.17.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -119,7 +119,8 @@ describe('Scripts (hoisted and not)', () => {
|
||||||
let html = await fixture.readFile('/with-styles/index.html');
|
let html = await fixture.readFile('/with-styles/index.html');
|
||||||
let $ = cheerio.load(html);
|
let $ = cheerio.load(html);
|
||||||
|
|
||||||
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(1);
|
// Imported styles + tailwind
|
||||||
|
expect($('link[rel=stylesheet]')).to.have.a.lengthOf(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -150,5 +151,21 @@ describe('Scripts (hoisted and not)', () => {
|
||||||
});
|
});
|
||||||
expect(found).to.equal(1);
|
expect(found).to.equal(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Using injectScript does not interfere', async () => {
|
||||||
|
let res = await fixture.fetch('/inline-in-page');
|
||||||
|
let html = await res.text();
|
||||||
|
let $ = cheerio.load(html);
|
||||||
|
let found = 0;
|
||||||
|
let moduleScripts = $('[type=module]');
|
||||||
|
moduleScripts.each((i, el) => {
|
||||||
|
if (
|
||||||
|
$(el).attr('src').includes('?astro&type=script&index=0&lang.ts')
|
||||||
|
) {
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expect(found).to.equal(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
8
packages/astro/test/fixtures/astro-scripts/astro.config.mjs
vendored
Normal file
8
packages/astro/test/fixtures/astro-scripts/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import tailwind from '@astrojs/tailwind';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
integrations: [
|
||||||
|
tailwind()
|
||||||
|
]
|
||||||
|
})
|
|
@ -3,6 +3,7 @@
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"astro": "workspace:*"
|
"astro": "workspace:*",
|
||||||
|
"@astrojs/tailwind": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro
vendored
Normal file
12
packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Testing</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Testing</h1>
|
||||||
|
<script>
|
||||||
|
console.log('hi');
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -404,7 +404,7 @@ importers:
|
||||||
recast: ^0.20.5
|
recast: ^0.20.5
|
||||||
rehype: ^12.0.1
|
rehype: ^12.0.1
|
||||||
resolve: ^1.22.0
|
resolve: ^1.22.0
|
||||||
rollup: ~2.77.0
|
rollup: ~2.78.0
|
||||||
sass: ^1.52.2
|
sass: ^1.52.2
|
||||||
semver: ^7.3.7
|
semver: ^7.3.7
|
||||||
shiki: ^0.11.1
|
shiki: ^0.11.1
|
||||||
|
@ -417,7 +417,7 @@ importers:
|
||||||
tsconfig-resolver: ^3.0.1
|
tsconfig-resolver: ^3.0.1
|
||||||
unist-util-visit: ^4.1.0
|
unist-util-visit: ^4.1.0
|
||||||
vfile: ^5.3.2
|
vfile: ^5.3.2
|
||||||
vite: 3.0.9
|
vite: 3.1.0
|
||||||
yargs-parser: ^21.0.1
|
yargs-parser: ^21.0.1
|
||||||
zod: ^3.17.3
|
zod: ^3.17.3
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -464,7 +464,7 @@ importers:
|
||||||
recast: 0.20.5
|
recast: 0.20.5
|
||||||
rehype: 12.0.1
|
rehype: 12.0.1
|
||||||
resolve: 1.22.1
|
resolve: 1.22.1
|
||||||
rollup: 2.77.3
|
rollup: 2.78.1
|
||||||
semver: 7.3.7
|
semver: 7.3.7
|
||||||
shiki: 0.11.1
|
shiki: 0.11.1
|
||||||
sirv: 2.0.2
|
sirv: 2.0.2
|
||||||
|
@ -475,7 +475,7 @@ importers:
|
||||||
tsconfig-resolver: 3.0.1
|
tsconfig-resolver: 3.0.1
|
||||||
unist-util-visit: 4.1.1
|
unist-util-visit: 4.1.1
|
||||||
vfile: 5.3.5
|
vfile: 5.3.5
|
||||||
vite: 3.0.9_sass@1.54.9
|
vite: 3.1.0_sass@1.54.9
|
||||||
yargs-parser: 21.1.1
|
yargs-parser: 21.1.1
|
||||||
zod: 3.19.1
|
zod: 3.19.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
@ -1356,8 +1356,10 @@ importers:
|
||||||
|
|
||||||
packages/astro/test/fixtures/astro-scripts:
|
packages/astro/test/fixtures/astro-scripts:
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@astrojs/tailwind': workspace:*
|
||||||
astro: workspace:*
|
astro: workspace:*
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@astrojs/tailwind': link:../../../../integrations/tailwind
|
||||||
astro: link:../../..
|
astro: link:../../..
|
||||||
|
|
||||||
packages/astro/test/fixtures/astro-sitemap-rss:
|
packages/astro/test/fixtures/astro-sitemap-rss:
|
||||||
|
@ -15819,14 +15821,6 @@ packages:
|
||||||
dependencies:
|
dependencies:
|
||||||
estree-walker: 0.6.1
|
estree-walker: 0.6.1
|
||||||
|
|
||||||
/rollup/2.77.3:
|
|
||||||
resolution: {integrity: sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==}
|
|
||||||
engines: {node: '>=10.0.0'}
|
|
||||||
hasBin: true
|
|
||||||
optionalDependencies:
|
|
||||||
fsevents: 2.3.2
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/rollup/2.78.1:
|
/rollup/2.78.1:
|
||||||
resolution: {integrity: sha512-VeeCgtGi4P+o9hIg+xz4qQpRl6R401LWEXBmxYKOV4zlF82lyhgh2hTZnheFUbANE8l2A41F458iwj2vEYaXJg==}
|
resolution: {integrity: sha512-VeeCgtGi4P+o9hIg+xz4qQpRl6R401LWEXBmxYKOV4zlF82lyhgh2hTZnheFUbANE8l2A41F458iwj2vEYaXJg==}
|
||||||
engines: {node: '>=10.0.0'}
|
engines: {node: '>=10.0.0'}
|
||||||
|
@ -17328,34 +17322,6 @@ packages:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vite/3.0.9_sass@1.54.9:
|
|
||||||
resolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
|
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
|
||||||
hasBin: true
|
|
||||||
peerDependencies:
|
|
||||||
less: '*'
|
|
||||||
sass: '*'
|
|
||||||
stylus: '*'
|
|
||||||
terser: ^5.4.0
|
|
||||||
peerDependenciesMeta:
|
|
||||||
less:
|
|
||||||
optional: true
|
|
||||||
sass:
|
|
||||||
optional: true
|
|
||||||
stylus:
|
|
||||||
optional: true
|
|
||||||
terser:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
esbuild: 0.14.54
|
|
||||||
postcss: 8.4.16
|
|
||||||
resolve: 1.22.1
|
|
||||||
rollup: 2.77.3
|
|
||||||
sass: 1.54.9
|
|
||||||
optionalDependencies:
|
|
||||||
fsevents: 2.3.2
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/vite/3.1.0:
|
/vite/3.1.0:
|
||||||
resolution: {integrity: sha512-YBg3dUicDpDWFCGttmvMbVyS9ydjntwEjwXRj2KBFwSB8SxmGcudo1yb8FW5+M/G86aS8x828ujnzUVdsLjs9g==}
|
resolution: {integrity: sha512-YBg3dUicDpDWFCGttmvMbVyS9ydjntwEjwXRj2KBFwSB8SxmGcudo1yb8FW5+M/G86aS8x828ujnzUVdsLjs9g==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
@ -17383,6 +17349,34 @@ packages:
|
||||||
fsevents: 2.3.2
|
fsevents: 2.3.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/vite/3.1.0_sass@1.54.9:
|
||||||
|
resolution: {integrity: sha512-YBg3dUicDpDWFCGttmvMbVyS9ydjntwEjwXRj2KBFwSB8SxmGcudo1yb8FW5+M/G86aS8x828ujnzUVdsLjs9g==}
|
||||||
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
|
hasBin: true
|
||||||
|
peerDependencies:
|
||||||
|
less: '*'
|
||||||
|
sass: '*'
|
||||||
|
stylus: '*'
|
||||||
|
terser: ^5.4.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
less:
|
||||||
|
optional: true
|
||||||
|
sass:
|
||||||
|
optional: true
|
||||||
|
stylus:
|
||||||
|
optional: true
|
||||||
|
terser:
|
||||||
|
optional: true
|
||||||
|
dependencies:
|
||||||
|
esbuild: 0.15.7
|
||||||
|
postcss: 8.4.16
|
||||||
|
resolve: 1.22.1
|
||||||
|
rollup: 2.78.1
|
||||||
|
sass: 1.54.9
|
||||||
|
optionalDependencies:
|
||||||
|
fsevents: 2.3.2
|
||||||
|
dev: false
|
||||||
|
|
||||||
/vitest/0.20.3:
|
/vitest/0.20.3:
|
||||||
resolution: {integrity: sha512-cXMjTbZxBBUUuIF3PUzEGPLJWtIMeURBDXVxckSHpk7xss4JxkiiWh5cnIlfGyfJne2Ii3QpbiRuFL5dMJtljw==}
|
resolution: {integrity: sha512-cXMjTbZxBBUUuIF3PUzEGPLJWtIMeURBDXVxckSHpk7xss4JxkiiWh5cnIlfGyfJne2Ii3QpbiRuFL5dMJtljw==}
|
||||||
engines: {node: '>=v14.16.0'}
|
engines: {node: '>=v14.16.0'}
|
||||||
|
|
Loading…
Reference in a new issue