From 0247b54270e2befab91b9e65029ba929ac26381d Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Tue, 19 Apr 2022 13:52:15 -0400 Subject: [PATCH] Refactor: remove all legacy build logic from codebase (#3141) * refactor: remove legacy build flag * refactor: remove legacy style maps * chore: changeset * refactor: nuke vite-plugin-build-html * deps: remove parse5 * tests: restore user provided doctype support! * deps: remove @web/parse5-utils * deps: change srcset-parse to dev dep * chore: remove unused utils * refactor: remove unused style mapping * unrelated fix: add .test to astro-markdown-css * refactor: remove unused astro-style with test update * chore: remove unused buildTime var --- .changeset/three-pigs-hunt.md | 5 + packages/astro/package.json | 6 +- packages/astro/src/@types/astro.ts | 1 - packages/astro/src/cli/index.ts | 1 - packages/astro/src/core/app/index.ts | 1 - packages/astro/src/core/build/generate.ts | 1 - packages/astro/src/core/build/index.ts | 1 - packages/astro/src/core/build/internal.ts | 21 - packages/astro/src/core/build/static-build.ts | 2 - packages/astro/src/core/path.ts | 8 - packages/astro/src/core/render/core.ts | 3 - packages/astro/src/core/render/dev/index.ts | 82 +-- packages/astro/src/core/render/result.ts | 38 +- packages/astro/src/runtime/server/index.ts | 13 +- .../astro/src/vite-plugin-build-css/index.ts | 53 +- .../add-rollup-input.ts | 43 -- .../vite-plugin-build-html/extract-assets.ts | 229 -------- .../astro/src/vite-plugin-build-html/index.ts | 537 ------------------ .../astro/src/vite-plugin-build-html/util.ts | 64 --- packages/astro/test/0-css.test.js | 4 +- packages/astro/test/astro-doctype.test.js | 12 +- ...down-css.js => astro-markdown-css.test.js} | 0 pnpm-lock.yaml | 16 +- 23 files changed, 55 insertions(+), 1086 deletions(-) create mode 100644 .changeset/three-pigs-hunt.md delete mode 100644 packages/astro/src/vite-plugin-build-html/add-rollup-input.ts delete mode 100644 packages/astro/src/vite-plugin-build-html/extract-assets.ts delete mode 100644 packages/astro/src/vite-plugin-build-html/index.ts delete mode 100644 packages/astro/src/vite-plugin-build-html/util.ts rename packages/astro/test/{astro-markdown-css.js => astro-markdown-css.test.js} (100%) diff --git a/.changeset/three-pigs-hunt.md b/.changeset/three-pigs-hunt.md new file mode 100644 index 000000000..c72222676 --- /dev/null +++ b/.changeset/three-pigs-hunt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Astro internals: remove all legacy build logic from the codebase, now that the legacy build flag has been removed diff --git a/packages/astro/package.json b/packages/astro/package.json index 7567193fb..769285d31 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -86,7 +86,6 @@ "@babel/traverse": "^7.17.9", "@proload/core": "^0.2.2", "@proload/plugin-tsm": "^0.1.1", - "@web/parse5-utils": "^1.3.0", "ast-types": "^0.14.2", "boxen": "^6.2.1", "ci-info": "^3.3.0", @@ -109,7 +108,6 @@ "micromorph": "^0.1.2", "mime": "^3.0.0", "ora": "^6.1.0", - "parse5": "^6.0.1", "path-browserify": "^1.0.1", "path-to-regexp": "^6.2.0", "postcss": "^8.4.12", @@ -128,7 +126,6 @@ "sirv": "^2.0.2", "slash": "^4.0.0", "sourcemap-codec": "^1.4.8", - "srcset-parse": "^1.1.0", "string-width": "^5.1.2", "strip-ansi": "^7.0.1", "supports-esm": "^1.0.0", @@ -163,7 +160,8 @@ "chai": "^4.3.6", "cheerio": "^1.0.0-rc.10", "mocha": "^9.2.2", - "sass": "^1.50.0" + "sass": "^1.50.0", + "srcset-parse": "^1.1.0" }, "engines": { "node": "^14.15.0 || >=16.0.0", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ffb62a15f..3047ae1b2 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -983,7 +983,6 @@ export interface SSRElement { export interface SSRMetadata { renderers: SSRLoadedRenderer[]; pathname: string; - legacyBuild: boolean; } export interface SSRResult { diff --git a/packages/astro/src/cli/index.ts b/packages/astro/src/cli/index.ts index 308ab6a5f..45f50f832 100644 --- a/packages/astro/src/cli/index.ts +++ b/packages/astro/src/cli/index.ts @@ -48,7 +48,6 @@ function printAstroHelp() { ['--host [optional IP]', 'Expose server on network'], ['--config ', 'Specify the path to the Astro config file.'], ['--root ', 'Specify the path to the project root folder.'], - ['--legacy-build', 'Use the build strategy prior to 0.24.0'], ['--drafts', 'Include markdown draft pages in the build.'], ['--verbose', 'Enable verbose logging'], ['--silent', 'Disable logging'], diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index c2f5d9a2e..6fb2d61be 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -78,7 +78,6 @@ export class App { const scripts = createModuleScriptElementWithSrcSet(info.scripts, manifest.site); const result = await render({ - legacyBuild: false, links, logging: this.#logging, markdown: manifest.markdown, diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 17b419bb4..36c25546c 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -193,7 +193,6 @@ async function generatePath( const ssr = isBuildingToSSR(opts.astroConfig); const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin); const options: RenderOptions = { - legacyBuild: false, links, logging, markdown: astroConfig.markdown, diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 98c8f1e8d..d0c0a026c 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -213,7 +213,6 @@ class AstroBuilder { pageCount: number; buildMode: 'static' | 'ssr'; }) { - const buildTime = performance.now() - timeStart; const total = getTimeStat(timeStart, performance.now()); let messages: string[] = []; diff --git a/packages/astro/src/core/build/internal.ts b/packages/astro/src/core/build/internal.ts index e51e0e5da..9edde85f3 100644 --- a/packages/astro/src/core/build/internal.ts +++ b/packages/astro/src/core/build/internal.ts @@ -30,24 +30,6 @@ export interface BuildInternals { * A map for page-specific information by a client:only component */ pagesByClientOnly: Map>; - - /** - * chunkToReferenceIdMap maps them to a hash id used to find the final file. - * @deprecated This Map is only used for the legacy build. - */ - chunkToReferenceIdMap: Map; - - /** - * This is a mapping of pathname to the string source of all collected inline