From f0181bd2ea6a4db9d63f041fb5bf1b3630c25b82 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:50:00 +0100 Subject: [PATCH 1/9] add runtime --- .eslintrc.cjs | 2 +- package.json | 9 ++++++++ pnpm-lock.yaml | 19 ++++++++++++----- src/core/unplugin-factory.ts | 40 ++++++++++++++++++++++++++++++++++++ src/runtime.ts | 1 + 5 files changed, 65 insertions(+), 6 deletions(-) create mode 100644 src/runtime.ts diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 86d6f40..ce0d462 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -24,7 +24,7 @@ module.exports = defineConfig({ rules: {}, }, { - files: ["esbuild.ts", "index.ts", "rollup.ts", "rspack.ts", "vite.ts", "webpack.ts", "nuxt.ts"], + files: ["esbuild.ts", "index.ts", "rollup.ts", "rspack.ts", "vite.ts", "webpack.ts", "nuxt.ts", "runtime.ts"], rules: { "import/no-unused-modules": "off", }, diff --git a/package.json b/package.json index 370d541..6264729 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,12 @@ "types": "./dist/nuxt.d.mts", "default": "./dist/nuxt.mjs" }, + "./runtime": { + "import": { + "types": "./dist/runtime.d.mts", + "default": "./dist/runtime.mjs" + } + }, "./package.json": "./package.json" }, "module": "dist/index.mjs", @@ -111,6 +117,9 @@ "consola": "3.2.3", "fast-json-stable-stringify": "^2.1.0", "find-cache-dir": "^5.0.0", + "knitwork": "1.1.0", + "magic-string": "0.30.10", + "mlly": "1.7.1", "parse-author": "^2.0.0", "parse5": "^7.1.2", "read-pkg-up": "^10.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 09c4276..247368e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,6 +37,15 @@ importers: find-cache-dir: specifier: ^5.0.0 version: 5.0.0 + knitwork: + specifier: 1.1.0 + version: 1.1.0 + magic-string: + specifier: 0.30.10 + version: 0.30.10 + mlly: + specifier: 1.7.1 + version: 1.7.1 parse-author: specifier: ^2.0.0 version: 2.0.0 @@ -20357,8 +20366,8 @@ snapshots: eslint-mdx@2.2.0(eslint@8.57.0): dependencies: - acorn: 8.10.0 - acorn-jsx: 5.3.2(acorn@8.10.0) + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) eslint: 8.57.0 espree: 9.6.1 estree-util-visit: 1.2.1 @@ -22713,7 +22722,7 @@ snapshots: jsonc-eslint-parser@2.4.0: dependencies: - acorn: 8.10.0 + acorn: 8.12.1 eslint-visitor-keys: 3.4.3 espree: 9.6.1 semver: 7.5.4 @@ -23926,8 +23935,8 @@ snapshots: micromark-extension-mdxjs@1.0.1: dependencies: - acorn: 8.10.0 - acorn-jsx: 5.3.2(acorn@8.10.0) + acorn: 8.12.1 + acorn-jsx: 5.3.2(acorn@8.12.1) micromark-extension-mdx-expression: 1.0.8 micromark-extension-mdx-jsx: 1.0.5 micromark-extension-mdx-md: 1.0.1 diff --git a/src/core/unplugin-factory.ts b/src/core/unplugin-factory.ts index 332a4fd..0c38442 100644 --- a/src/core/unplugin-factory.ts +++ b/src/core/unplugin-factory.ts @@ -3,6 +3,9 @@ import { join } from "node:path"; import type { Compilation as RspackCompilation } from "@rspack/core"; import { colorize } from "consola/utils"; import type { FaviconResponse } from "favicons"; +import { genString } from "knitwork"; +import MagicString from "magic-string"; +import { findStaticImports, parseStaticImport } from "mlly"; import type { OutputAsset, OutputChunk } from "rollup"; import type { UnpluginBuildContext, UnpluginFactory } from "unplugin"; import type { Compilation as WebpackCompilation } from "webpack"; @@ -24,6 +27,8 @@ const unpluginFactory: UnpluginFactory index.specifier === runtimePackageName); + if (statements.length === 0) { + return undefined; + } + + statements.forEach((index) => { + const im = parseStaticImport(index); + const html = parsedHtml.map((tag) => tag.fragment).join(""); + const generatedCode = `const ${im.defaultImport ?? im.imports} = ${genString(html)};`; + s.overwrite(im.start, im.end, generatedCode); + }); + + if (!s.hasChanged()) { + return undefined; + } + + return { + code: s.toString(), + map: s.generateMap({ + includeContent: true, + source: id, + }), + }; + }, + transformInclude(id) { + return id.match(/\.((c|m)?j|t)sx?$/u); + }, vite: { configResolved(viteConfig) { base = viteConfig.base; diff --git a/src/runtime.ts b/src/runtime.ts new file mode 100644 index 0000000..9cf3c27 --- /dev/null +++ b/src/runtime.ts @@ -0,0 +1 @@ +export default ""; From ab7ecc1beb32b2684ef7fe1c763d8e739ccd2744 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:56:50 +0100 Subject: [PATCH 2/9] use `config.outputPath` for `favicons.path` when not defineded --- src/core/unplugin-factory.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/unplugin-factory.ts b/src/core/unplugin-factory.ts index 0c38442..561b2ca 100644 --- a/src/core/unplugin-factory.ts +++ b/src/core/unplugin-factory.ts @@ -150,7 +150,13 @@ const unpluginFactory: UnpluginFactory Date: Fri, 26 Jul 2024 21:57:14 +0100 Subject: [PATCH 3/9] use runtime in sveltekit --- examples/sveltekit/src/hooks.server.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 examples/sveltekit/src/hooks.server.ts diff --git a/examples/sveltekit/src/hooks.server.ts b/examples/sveltekit/src/hooks.server.ts new file mode 100644 index 0000000..eae7e44 --- /dev/null +++ b/examples/sveltekit/src/hooks.server.ts @@ -0,0 +1,9 @@ +import head from "@anolilab/unplugin-favicons/runtime"; +import type { Handle } from "@sveltejs/kit"; + +export const handle: Handle = async ({ event, resolve }) => { + const response = await resolve(event, { + transformPageChunk: ({ html }) => html.replace("", `${head}`), + }); + return response; +}; From 273b74372a74e70e502594c20179c199bc83d491 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:13:28 +0100 Subject: [PATCH 4/9] update readme for sveltekit --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 502c6c8..f63d096 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ See [the Nuxt example](examples/nuxt) for a working example project.
-SvelteKit (No Supported for now, see Vite Plugin)
+SvelteKit The `@anolilab/unplugin-favicons` plugin should be configured in the `vite.config.js` configuration file: @@ -219,6 +219,20 @@ export default defineConfig({ }); ``` +Then add `src/hooks.server.ts` to rewrite the head tag with [`hooks`](https://kit.svelte.dev/docs/hooks): + +```ts +import head from "@anolilab/unplugin-favicons/runtime"; // use default import +import type { Handle } from "@sveltejs/kit"; + +export const handle: Handle = async ({ event, resolve }) => { + const response = await resolve(event, { + transformPageChunk: ({ html }) => html.replace("", `${head}`), + }); + return response; +}; +``` + Check instructions in the `Frameworks -> Svelte` section below if you faced module import errors. See [the SvelteKit example](examples/sveltekit) for a working example project. From bf1d90f320a624b6a536823d625d711845c52eb4 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:20:25 +0100 Subject: [PATCH 5/9] raise error when importing `runtime` without plugin --- src/runtime.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runtime.ts b/src/runtime.ts index 9cf3c27..801df0d 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -1 +1,2 @@ +throw new Error("You should config @anolilab/unplugin-favicons/vite in `vite.config.ts` first"); export default ""; From 604938b8590b127a9cb32a1efdce914ed81e8c98 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:20:58 +0100 Subject: [PATCH 6/9] migrate to sveltekit2 https://kit.svelte.dev/docs/migrating-to-sveltekit-2#vitepreprocess-is-no-longer-exported-from-sveltejs-kit-vite --- examples/sveltekit/package.json | 1 + examples/sveltekit/svelte.config.js | 2 +- pnpm-lock.yaml | 116 +++++++++++++++------------- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/examples/sveltekit/package.json b/examples/sveltekit/package.json index 2f7ebab..c696390 100644 --- a/examples/sveltekit/package.json +++ b/examples/sveltekit/package.json @@ -15,6 +15,7 @@ "@neoconfetti/svelte": "^2.2.1", "@sveltejs/adapter-auto": "^3.2.2", "@sveltejs/kit": "^2.5.18", + "@sveltejs/vite-plugin-svelte": "3.1.1", "@types/cookie": "^0.6.0", "svelte": "^4.2.18", "svelte-check": "^3.8.4", diff --git a/examples/sveltekit/svelte.config.js b/examples/sveltekit/svelte.config.js index bdc3248..90c0afc 100644 --- a/examples/sveltekit/svelte.config.js +++ b/examples/sveltekit/svelte.config.js @@ -1,5 +1,5 @@ import adapter from "@sveltejs/adapter-auto"; -import { vitePreprocess } from "@sveltejs/kit/vite"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; /** @type {import('@sveltejs/kit').Config} */ const config = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 247368e..2713bd9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -461,6 +461,9 @@ importers: '@sveltejs/kit': specifier: ^2.5.18 version: 2.5.18(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)))(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)) + '@sveltejs/vite-plugin-svelte': + specifier: 3.1.1 + version: 3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)) '@types/cookie': specifier: ^0.6.0 version: 0.6.0 @@ -3911,6 +3914,7 @@ packages: '@tsconfig/esm@1.0.5': resolution: {integrity: sha512-JzoZ0h299JRLPfV5VBsMq1TuMy+OmU9bdV/7NcjfRojL0eIcA1k5ESrtjWrDwJRJnk9B0QmgR0rq04LERbdfWw==} + deprecated: this package has been deprecated '@tsconfig/node10@1.0.9': resolution: {integrity: sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==} @@ -7208,6 +7212,7 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} @@ -7691,6 +7696,7 @@ packages: inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. inherits@2.0.3: resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} @@ -15369,7 +15375,7 @@ snapshots: '@eslint/config-array@0.17.0': dependencies: '@eslint/object-schema': 2.1.4 - debug: 4.3.4 + debug: 4.3.5 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -15377,7 +15383,7 @@ snapshots: '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.5 espree: 9.6.1 globals: 13.23.0 ignore: 5.2.4 @@ -15391,7 +15397,7 @@ snapshots: '@eslint/eslintrc@3.1.0': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.5 espree: 10.1.0 globals: 14.0.0 ignore: 5.2.4 @@ -15421,7 +15427,7 @@ snapshots: '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.4 + debug: 4.3.5 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -16617,7 +16623,7 @@ snapshots: '@secretlint/profiler': 8.2.4 '@secretlint/types': 8.2.4 ajv: 8.12.0 - debug: 4.3.4 + debug: 4.3.5 rc-config-loader: 4.1.3 try-resolve: 1.0.1 transitivePeerDependencies: @@ -16627,7 +16633,7 @@ snapshots: dependencies: '@secretlint/profiler': 8.2.4 '@secretlint/types': 8.2.4 - debug: 4.3.4 + debug: 4.3.5 structured-source: 4.0.0 transitivePeerDependencies: - supports-color @@ -16639,7 +16645,7 @@ snapshots: '@textlint/module-interop': 13.4.1 '@textlint/types': 12.6.1 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 is-file: 1.0.0 pluralize: 8.0.0 strip-ansi: 6.0.1 @@ -16657,7 +16663,7 @@ snapshots: '@secretlint/profiler': 8.2.4 '@secretlint/source-creator': 8.2.4 '@secretlint/types': 8.2.4 - debug: 4.3.4 + debug: 4.3.5 p-map: 4.0.0 transitivePeerDependencies: - supports-color @@ -16687,7 +16693,7 @@ snapshots: conventional-changelog-writer: 8.0.0 conventional-commits-filter: 5.0.0 conventional-commits-parser: 6.0.0 - debug: 4.3.4 + debug: 4.3.5 import-from-esm: 1.3.4 lodash-es: 4.17.21 micromatch: 4.0.5 @@ -16703,7 +16709,7 @@ snapshots: dependencies: '@semantic-release/error': 3.0.0 aggregate-error: 3.1.0 - debug: 4.3.4 + debug: 4.3.5 execa: 5.1.1 lodash: 4.17.21 parse-json: 5.2.0 @@ -16715,7 +16721,7 @@ snapshots: dependencies: '@semantic-release/error': 3.0.0 aggregate-error: 3.1.0 - debug: 4.3.4 + debug: 4.3.5 dir-glob: 3.0.1 execa: 5.1.1 lodash: 4.17.21 @@ -16733,7 +16739,7 @@ snapshots: '@octokit/plugin-throttling': 9.3.1(@octokit/core@6.1.2) '@semantic-release/error': 4.0.0 aggregate-error: 5.0.0 - debug: 4.3.4 + debug: 4.3.5 dir-glob: 3.0.1 globby: 14.0.2 http-proxy-agent: 7.0.0 @@ -16770,7 +16776,7 @@ snapshots: conventional-changelog-writer: 8.0.0 conventional-commits-filter: 5.0.0 conventional-commits-parser: 6.0.0 - debug: 4.3.4 + debug: 4.3.5 get-stream: 7.0.1 import-from-esm: 1.3.4 into-stream: 7.0.0 @@ -16786,7 +16792,7 @@ snapshots: conventional-changelog-writer: 8.0.0 conventional-commits-filter: 5.0.0 conventional-commits-parser: 6.0.0 - debug: 4.3.4 + debug: 4.3.5 get-stream: 7.0.1 import-from-esm: 1.3.4 into-stream: 7.0.0 @@ -16866,7 +16872,7 @@ snapshots: '@sveltejs/vite-plugin-svelte-inspector@2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)))(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3))': dependencies: '@sveltejs/vite-plugin-svelte': 3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)) - debug: 4.3.4 + debug: 4.3.5 svelte: 4.2.18 vite: 5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3) transitivePeerDependencies: @@ -16875,7 +16881,7 @@ snapshots: '@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3))': dependencies: '@sveltejs/vite-plugin-svelte-inspector': 2.1.0(@sveltejs/vite-plugin-svelte@3.1.1(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)))(svelte@4.2.18)(vite@5.3.4(@types/node@20.14.11)(less@4.2.0)(sass@1.77.6)(terser@5.31.3)) - debug: 4.3.4 + debug: 4.3.5 deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.10 @@ -17027,14 +17033,14 @@ snapshots: '@textlint/ast-tester@12.6.1': dependencies: '@textlint/ast-node-types': 12.6.1 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color '@textlint/ast-tester@14.0.4': dependencies: '@textlint/ast-node-types': 14.0.4 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -17052,7 +17058,7 @@ snapshots: '@textlint/module-interop': 14.0.4 '@textlint/types': 14.0.4 '@textlint/utils': 14.0.4 - debug: 4.3.4 + debug: 4.3.5 rc-config-loader: 4.1.3 try-resolve: 1.0.1 transitivePeerDependencies: @@ -17067,7 +17073,7 @@ snapshots: '@textlint/module-interop': 14.0.4 '@textlint/types': 14.0.4 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 diff: 5.2.0 string-width: 4.2.3 strip-ansi: 6.0.1 @@ -17085,7 +17091,7 @@ snapshots: '@textlint/source-code-fixer': 12.6.1 '@textlint/types': 12.6.1 '@textlint/utils': 12.6.1 - debug: 4.3.4 + debug: 4.3.5 deep-equal: 1.1.1 structured-source: 4.0.0 transitivePeerDependencies: @@ -17100,7 +17106,7 @@ snapshots: '@textlint/source-code-fixer': 14.0.4 '@textlint/types': 14.0.4 '@textlint/utils': 14.0.4 - debug: 4.3.4 + debug: 4.3.5 fast-equals: 4.0.3 structured-source: 4.0.0 transitivePeerDependencies: @@ -17113,7 +17119,7 @@ snapshots: '@textlint/module-interop': 12.6.1 '@textlint/types': 12.6.1 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 is-file: 1.0.0 js-yaml: 3.14.1 lodash: 4.17.21 @@ -17134,7 +17140,7 @@ snapshots: '@textlint/module-interop': 14.0.4 '@textlint/types': 14.0.4 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 js-yaml: 3.14.1 lodash: 4.17.21 pluralize: 2.0.0 @@ -17149,7 +17155,7 @@ snapshots: '@textlint/markdown-to-ast@12.6.1': dependencies: '@textlint/ast-node-types': 12.6.1 - debug: 4.3.4 + debug: 4.3.5 mdast-util-gfm-autolink-literal: 0.1.3 remark-footnotes: 3.0.0 remark-frontmatter: 3.0.0 @@ -17163,7 +17169,7 @@ snapshots: '@textlint/markdown-to-ast@14.0.4': dependencies: '@textlint/ast-node-types': 14.0.4 - debug: 4.3.4 + debug: 4.3.5 mdast-util-gfm-autolink-literal: 0.1.3 remark-footnotes: 3.0.0 remark-frontmatter: 3.0.0 @@ -17192,14 +17198,14 @@ snapshots: '@textlint/source-code-fixer@12.6.1': dependencies: '@textlint/types': 12.6.1 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color '@textlint/source-code-fixer@14.0.4': dependencies: '@textlint/types': 14.0.4 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -17579,7 +17585,7 @@ snapshots: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.5.3) '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 optionalDependencies: typescript: 5.5.3 @@ -17592,7 +17598,7 @@ snapshots: '@typescript-eslint/types': 6.7.4 '@typescript-eslint/typescript-estree': 6.7.4(typescript@5.2.2) '@typescript-eslint/visitor-keys': 6.7.4 - debug: 4.3.4 + debug: 4.3.5 eslint: 9.7.0 optionalDependencies: typescript: 5.2.2 @@ -17623,7 +17629,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 7.16.1(typescript@5.5.3) '@typescript-eslint/utils': 7.16.1(eslint@8.57.0)(typescript@5.5.3) - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.5.3) optionalDependencies: @@ -17643,7 +17649,7 @@ snapshots: dependencies: '@typescript-eslint/types': 5.59.11 '@typescript-eslint/visitor-keys': 5.59.11 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -17657,7 +17663,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -17672,7 +17678,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.7.4 '@typescript-eslint/visitor-keys': 6.7.4 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 @@ -17686,7 +17692,7 @@ snapshots: dependencies: '@typescript-eslint/types': 7.16.1 '@typescript-eslint/visitor-keys': 7.16.1 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.5 @@ -18288,13 +18294,13 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color agent-base@7.1.0: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -20332,7 +20338,7 @@ snapshots: eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-i@2.29.1(eslint@8.57.0))(eslint@8.57.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 enhanced-resolve: 5.15.0 eslint: 8.57.0 eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.21.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-i@2.29.1(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0) @@ -20349,7 +20355,7 @@ snapshots: eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.7.4(eslint@9.7.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@9.7.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 enhanced-resolve: 5.15.0 eslint: 9.7.0 eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.7.4(eslint@9.7.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@6.7.4(eslint@9.7.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@9.7.0))(eslint@9.7.0) @@ -20758,7 +20764,7 @@ snapshots: eslint-plugin-toml@0.6.1(eslint@8.57.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 eslint-compat-utils: 0.1.2(eslint@8.57.0) lodash: 4.17.21 @@ -20798,7 +20804,7 @@ snapshots: eslint-plugin-yml@1.14.0(eslint@8.57.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 eslint-compat-utils: 0.5.1(eslint@8.57.0) lodash: 4.17.21 @@ -21510,7 +21516,7 @@ snapshots: git-spawned-stream@1.0.1: dependencies: - debug: 4.3.4 + debug: 4.3.5 spawn-to-readstream: 0.1.3 transitivePeerDependencies: - supports-color @@ -22039,7 +22045,7 @@ snapshots: http-proxy-agent@7.0.0: dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -22096,14 +22102,14 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color https-proxy-agent@7.0.2: dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -22170,7 +22176,7 @@ snapshots: import-from-esm@1.3.4: dependencies: - debug: 4.3.4 + debug: 4.3.5 import-meta-resolve: 4.1.0 transitivePeerDependencies: - supports-color @@ -22252,7 +22258,7 @@ snapshots: dependencies: '@ioredis/commands': 1.2.0 cluster-key-slot: 1.1.2 - debug: 4.3.4 + debug: 4.3.5 denque: 2.1.0 lodash.defaults: 4.2.0 lodash.isarguments: 3.1.0 @@ -24185,7 +24191,7 @@ snapshots: micromark@2.11.4: dependencies: - debug: 4.3.4 + debug: 4.3.5 parse-entities: 2.0.0 transitivePeerDependencies: - supports-color @@ -24193,7 +24199,7 @@ snapshots: micromark@3.2.0: dependencies: '@types/debug': 4.1.9 - debug: 4.3.4 + debug: 4.3.5 decode-named-character-reference: 1.0.2 micromark-core-commonmark: 1.1.0 micromark-factory-space: 1.1.0 @@ -24215,7 +24221,7 @@ snapshots: micromark@4.0.0: dependencies: '@types/debug': 4.1.9 - debug: 4.3.4 + debug: 4.3.5 decode-named-character-reference: 1.0.2 devlop: 1.1.0 micromark-core-commonmark: 2.0.1 @@ -25823,7 +25829,7 @@ snapshots: rc-config-loader@4.1.3: dependencies: - debug: 4.3.4 + debug: 4.3.5 js-yaml: 4.1.0 json5: 2.2.3 require-from-string: 2.0.2 @@ -27052,7 +27058,7 @@ snapshots: spdy-transport@3.0.0: dependencies: - debug: 4.3.4 + debug: 4.3.5 detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -27063,7 +27069,7 @@ snapshots: spdy@4.0.2: dependencies: - debug: 4.3.4 + debug: 4.3.5 handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -28069,7 +28075,7 @@ snapshots: '@types/node': 18.18.3 '@types/unist': 2.0.8 concat-stream: 2.0.0 - debug: 4.3.4 + debug: 4.3.5 fault: 2.0.1 glob: 8.1.0 ignore: 5.2.4 @@ -28096,7 +28102,7 @@ snapshots: '@types/node': 20.14.11 '@types/unist': 3.0.0 concat-stream: 2.0.0 - debug: 4.3.4 + debug: 4.3.5 extend: 3.0.2 glob: 10.3.10 ignore: 5.2.4 From e642f491a9515d752cbe299fc3def0f5359ca8bb Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:26:20 +0100 Subject: [PATCH 7/9] Revert "raise error when importing `runtime` without plugin" This reverts commit 4fda52ebdcfe5a2e08f695e2512b95629ce6068f. --- src/runtime.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime.ts b/src/runtime.ts index 801df0d..9cf3c27 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -1,2 +1 @@ -throw new Error("You should config @anolilab/unplugin-favicons/vite in `vite.config.ts` first"); export default ""; From 88ad66567595b142aa4cbc0f6f0f92a4518c1bf1 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:33:14 +0100 Subject: [PATCH 8/9] add favicon config for sveltekit --- examples/sveltekit/src/app.html | 1 - examples/sveltekit/vite.config.ts | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/sveltekit/src/app.html b/examples/sveltekit/src/app.html index af1e545..ff0b784 100644 --- a/examples/sveltekit/src/app.html +++ b/examples/sveltekit/src/app.html @@ -2,7 +2,6 @@ - %sveltekit.head% diff --git a/examples/sveltekit/vite.config.ts b/examples/sveltekit/vite.config.ts index a9efea8..8316279 100644 --- a/examples/sveltekit/vite.config.ts +++ b/examples/sveltekit/vite.config.ts @@ -3,5 +3,10 @@ import { defineConfig } from "vite"; import faviconsPlugin from "@anolilab/unplugin-favicons/vite"; export default defineConfig({ - plugins: [sveltekit(), faviconsPlugin()], + plugins: [ + sveltekit(), + faviconsPlugin({ + logo: "./static/favicon.png", + }), + ], }); From b71b324d4cbd8a24f4b060d80127aedf578aad38 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Fri, 26 Jul 2024 22:35:04 +0100 Subject: [PATCH 9/9] add `unplugin-favicons` prefix for sveltekit outputPath --- src/core/unplugin-factory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/unplugin-factory.ts b/src/core/unplugin-factory.ts index 561b2ca..6749ce8 100644 --- a/src/core/unplugin-factory.ts +++ b/src/core/unplugin-factory.ts @@ -250,7 +250,7 @@ const unpluginFactory: UnpluginFactory { if (frontendFramework === undefined && plugin.name.includes("sveltekit")) { frontendFramework = "sveltekit"; - config.outputPath = "_app/immutable/assets/"; + config.outputPath = "_app/immutable/assets/unplugin-favicons"; } else if (frontendFramework === undefined && plugin.name.includes("astro")) { frontendFramework = "astro"; } else if (frontendFramework === undefined && plugin.name.includes("vike")) {