diff --git a/packages/astro/test/astro-scripts.test.js b/packages/astro/test/astro-scripts.test.js index 1229de5f5..55097b7a5 100644 --- a/packages/astro/test/astro-scripts.test.js +++ b/packages/astro/test/astro-scripts.test.js @@ -150,5 +150,22 @@ describe('Scripts (hoisted and not)', () => { }); expect(found).to.equal(1); }); + + it.only('Using injectScript does not interfere', async () => { + let res = await fixture.fetch('/inline-in-page'); + let html = await res.text(); + let $ = cheerio.load(html); + //console.log(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); + }); }); }); diff --git a/packages/astro/test/fixtures/astro-scripts/astro.config.mjs b/packages/astro/test/fixtures/astro-scripts/astro.config.mjs new file mode 100644 index 000000000..440661908 --- /dev/null +++ b/packages/astro/test/fixtures/astro-scripts/astro.config.mjs @@ -0,0 +1,36 @@ +import { defineConfig } from 'astro/config'; +import tailwind from '@astrojs/tailwind'; + +export default defineConfig({ + integrations: [ + tailwind() + // { + // name: '@test-inject-script', + // hooks: { + // 'astro:config:setup'({ injectScript, updateConfig }) { + // injectScript('page-ssr', `import 'virtual:test';`); + // updateConfig({ + // vite: { + // plugins: [ + // { + // name: '@test-inject-script', + // resolveId(id) { + // if(id === 'virtual:test') { + // return id; + // } + // }, + // load(id) { + // if(id === 'virtual:test') { + // console.log('loading it'); + // return 'export default void 0;' + // } + // } + // } + // ] + // } + // }) + // } + // } + // } + ] +}) diff --git a/packages/astro/test/fixtures/astro-scripts/package.json b/packages/astro/test/fixtures/astro-scripts/package.json index 6d6da3520..5ec16b38e 100644 --- a/packages/astro/test/fixtures/astro-scripts/package.json +++ b/packages/astro/test/fixtures/astro-scripts/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "dependencies": { - "astro": "workspace:*" + "astro": "workspace:*", + "@astrojs/tailwind": "workspace:*" } } diff --git a/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro b/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro new file mode 100644 index 000000000..ce9e2733e --- /dev/null +++ b/packages/astro/test/fixtures/astro-scripts/src/pages/inline-in-page.astro @@ -0,0 +1,12 @@ + + +
+