summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/astro/src/core/build/generate.ts6
-rw-r--r--packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts5
-rw-r--r--packages/astro/src/core/build/vite-plugin-ssr.ts9
-rw-r--r--packages/astro/src/core/config/schema.ts14
-rw-r--r--packages/astro/test/asset-url-base.test.js12
-rw-r--r--packages/astro/test/astro-scripts.test.js8
-rw-r--r--packages/astro/test/ssr-request.test.js6
7 files changed, 33 insertions, 27 deletions
diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts
index a1e6e6489..a92006fe1 100644
--- a/packages/astro/src/core/build/generate.ts
+++ b/packages/astro/src/core/build/generate.ts
@@ -14,7 +14,6 @@ import type {
} from '../../@types/astro';
import type { BuildInternals } from '../../core/build/internal.js';
import {
- joinPaths,
prependForwardSlash,
removeLeadingForwardSlash,
removeTrailingForwardSlash,
@@ -292,7 +291,10 @@ async function generatePath(
debug('build', `Generating: ${pathname}`);
const links = createLinkStylesheetElementSet(linkIds, settings.config.base);
- const scripts = createModuleScriptsSet(hoistedScripts ? [hoistedScripts] : [], settings.config.base);
+ const scripts = createModuleScriptsSet(
+ hoistedScripts ? [hoistedScripts] : [],
+ settings.config.base
+ );
if (settings.scripts.some((script) => script.stage === 'page')) {
const hashedFilePath = internals.entrySpecifierToBundleMap.get(PAGE_SCRIPT_ID);
diff --git a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
index 7a90f00bb..65d38ec87 100644
--- a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
+++ b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts
@@ -41,7 +41,10 @@ export function vitePluginHoistedScripts(
async generateBundle(_options, bundle) {
let assetInlineLimit = 4096;
- if(settings.config.vite?.build && settings.config.vite.build.assetsInlineLimit !== undefined) {
+ if (
+ settings.config.vite?.build &&
+ settings.config.vite.build.assetsInlineLimit !== undefined
+ ) {
assetInlineLimit = settings.config.vite?.build.assetsInlineLimit;
}
diff --git a/packages/astro/src/core/build/vite-plugin-ssr.ts b/packages/astro/src/core/build/vite-plugin-ssr.ts
index 8cbc0a1b6..03dc20699 100644
--- a/packages/astro/src/core/build/vite-plugin-ssr.ts
+++ b/packages/astro/src/core/build/vite-plugin-ssr.ts
@@ -139,15 +139,16 @@ function buildManifest(
for (const pageData of eachPageData(internals)) {
const scripts: SerializedRouteInfo['scripts'] = [];
if (pageData.hoistedScript) {
- scripts.unshift(Object.assign({}, pageData.hoistedScript, {
- value: joinBase(pageData.hoistedScript.value)
- }));
+ scripts.unshift(
+ Object.assign({}, pageData.hoistedScript, {
+ value: joinBase(pageData.hoistedScript.value),
+ })
+ );
}
if (settings.scripts.some((script) => script.stage === 'page')) {
scripts.push({ type: 'external', value: entryModules[PAGE_SCRIPT_ID] });
}
-
const links = sortedCSS(pageData).map((pth) => joinBase(pth));
routes.push({
diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts
index 30b9f65dd..c2011926c 100644
--- a/packages/astro/src/core/config/schema.ts
+++ b/packages/astro/src/core/config/schema.ts
@@ -326,19 +326,19 @@ export function createRelativeSchema(cmd: string, fileProtocolRoot: URL) {
// If there is no base but there is a base for site config, warn.
const sitePathname = config.site && new URL(config.site).pathname;
- if(!trimmedBase.length && sitePathname && sitePathname !== '/') {
+ if (!trimmedBase.length && sitePathname && sitePathname !== '/') {
config.base = sitePathname;
/* eslint-disable no-console */
console.warn(`The site configuration value includes a pathname of ${sitePathname} but there is no base configuration.
-A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`)
+A future version of Astro will stop using the site pathname when producing <link> and <script> tags. Set your site's base with the base configuration.`);
}
- if(trimmedBase.length && config.trailingSlash === 'never') {
- config.base = prependForwardSlash(trimmedBase);
- } else {
- config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
- }
+ if (trimmedBase.length && config.trailingSlash === 'never') {
+ config.base = prependForwardSlash(trimmedBase);
+ } else {
+ config.base = prependForwardSlash(appendForwardSlash(trimmedBase));
+ }
return config;
});
diff --git a/packages/astro/test/asset-url-base.test.js b/packages/astro/test/asset-url-base.test.js
index a6d1c0677..0dc565b7f 100644
--- a/packages/astro/test/asset-url-base.test.js
+++ b/packages/astro/test/asset-url-base.test.js
@@ -11,12 +11,12 @@ describe('Asset URL resolution in build', () => {
before(async () => {
fixture = await loadFixture({
root: './fixtures/asset-url-base/',
- site: 'http://example.com/sub/path/'
+ site: 'http://example.com/sub/path/',
});
await fixture.build();
});
-
- it('does not include the site\'s subpath', async () => {
+
+ it("does not include the site's subpath", async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const href = $('link[rel=stylesheet]').attr('href');
@@ -29,12 +29,12 @@ describe('Asset URL resolution in build', () => {
fixture = await loadFixture({
root: './fixtures/asset-url-base/',
site: 'http://example.com/sub/path/',
- base: '/another/base/'
+ base: '/another/base/',
});
await fixture.build();
});
-
- it('does not include the site\'s subpath', async () => {
+
+ it("does not include the site's subpath", async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const href = $('link[rel=stylesheet]').attr('href');
diff --git a/packages/astro/test/astro-scripts.test.js b/packages/astro/test/astro-scripts.test.js
index 441f91b76..c65e33c8b 100644
--- a/packages/astro/test/astro-scripts.test.js
+++ b/packages/astro/test/astro-scripts.test.js
@@ -116,18 +116,18 @@ describe('Scripts (hoisted and not)', () => {
it('External page builds the hoisted scripts to a single bundle', async () => {
let external = await fixture.readFile('/external/index.html');
let $ = cheerio.load(external);
-
+
// test 1: there are two scripts
expect($('script')).to.have.lengthOf(2);
-
+
let el = $('script').get(1);
expect($(el).attr('src')).to.equal(undefined, 'This should have been inlined');
let externalEntryJS = $(el).text();
-
+
// test 2: the JS exists
expect(externalEntryJS).to.be.ok;
});
- })
+ });
});
describe('Dev', () => {
diff --git a/packages/astro/test/ssr-request.test.js b/packages/astro/test/ssr-request.test.js
index 42817abc5..446a3e05d 100644
--- a/packages/astro/test/ssr-request.test.js
+++ b/packages/astro/test/ssr-request.test.js
@@ -15,9 +15,9 @@ describe('Using Astro.request in SSR', () => {
base: '/subpath/',
vite: {
build: {
- assetsInlineLimit: 0
- }
- }
+ assetsInlineLimit: 0,
+ },
+ },
});
await fixture.build();
});