From 95ec9ef6d0158bced094cb9013581f45ac2b2995 Mon Sep 17 00:00:00 2001 From: p-sw Date: Mon, 3 Jun 2024 22:56:24 +0900 Subject: [PATCH] feat: add vite-plugin-dynamic-import --- packages/react/package.json | 3 ++- packages/react/vite.config.ts | 3 ++- yarn.lock | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/packages/react/package.json b/packages/react/package.json index 44cf3bd..c139f2b 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -40,6 +40,7 @@ "postcss": "^8.4.38", "tailwindcss": "^3.4.3", "typescript": "5.3.2", - "vite": "^5.2.0" + "vite": "^5.2.0", + "vite-plugin-dynamic-import": "^1.5.0" } } diff --git a/packages/react/vite.config.ts b/packages/react/vite.config.ts index 753dc39..fd84dde 100644 --- a/packages/react/vite.config.ts +++ b/packages/react/vite.config.ts @@ -8,10 +8,11 @@ import remarkGfm from "remark-gfm"; import withSlug from "rehype-slug" import withToc from "@stefanprobst/rehype-extract-toc"; import withTocExport from "@stefanprobst/rehype-extract-toc/mdx"; +import dynamicImport from 'vite-plugin-dynamic-import' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), mdx({ rehypePlugins: [rehypeHighlight, withSlug, withToc, withTocExport], remarkPlugins: [remarkGfm] })], + plugins: [react(), mdx({ rehypePlugins: [rehypeHighlight, withSlug, withToc, withTocExport], remarkPlugins: [remarkGfm] }), dynamicImport()], css: { postcss: { plugins: [tailwindcss()], diff --git a/yarn.lock b/yarn.lock index 2ea6742..c400894 100644 --- a/yarn.lock +++ b/yarn.lock @@ -553,7 +553,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14": +"@jridgewell/sourcemap-codec@npm:^1.4.10, @jridgewell/sourcemap-codec@npm:^1.4.14, @jridgewell/sourcemap-codec@npm:^1.4.15": version: 1.4.15 resolution: "@jridgewell/sourcemap-codec@npm:1.4.15" checksum: 10c0/0c6b5ae663087558039052a626d2d7ed5208da36cfd707dcc5cea4a07cfc918248403dcb5989a8f7afaf245ce0573b7cc6fd94c4a30453bd10e44d9363940ba5 @@ -1280,7 +1280,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.0.0, acorn@npm:^8.9.0": +"acorn@npm:^8.0.0, acorn@npm:^8.8.2, acorn@npm:^8.9.0": version: 8.11.3 resolution: "acorn@npm:8.11.3" bin: @@ -1838,6 +1838,13 @@ __metadata: languageName: node linkType: hard +"es-module-lexer@npm:^1.2.1": + version: 1.5.3 + resolution: "es-module-lexer@npm:1.5.3" + checksum: 10c0/0f50b655490d1048432eac6eec94d99d3933119666ae82be578c3db1ea4b2c594118a336f6b7a3c4e2815355dcc9a469d880acef1c45aa656a5aae8c8ae8e5f6 + languageName: node + linkType: hard + "esbuild@npm:^0.20.1": version: 0.20.2 resolution: "esbuild@npm:0.20.2" @@ -2205,7 +2212,7 @@ __metadata: languageName: node linkType: hard -"fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": +"fast-glob@npm:^3.2.12, fast-glob@npm:^3.2.9, fast-glob@npm:^3.3.0": version: 3.3.2 resolution: "fast-glob@npm:3.3.2" dependencies: @@ -3049,6 +3056,15 @@ __metadata: languageName: node linkType: hard +"magic-string@npm:^0.30.1": + version: 0.30.10 + resolution: "magic-string@npm:0.30.10" + dependencies: + "@jridgewell/sourcemap-codec": "npm:^1.4.15" + checksum: 10c0/aa9ca17eae571a19bce92c8221193b6f93ee8511abb10f085e55ffd398db8e4c089a208d9eac559deee96a08b7b24d636ea4ab92f09c6cf42a7d1af51f7fd62b + languageName: node + linkType: hard + "make-fetch-happen@npm:^13.0.0": version: 13.0.1 resolution: "make-fetch-happen@npm:13.0.1" @@ -4365,6 +4381,7 @@ __metadata: tailwindcss: "npm:^3.4.3" typescript: "npm:5.3.2" vite: "npm:^5.2.0" + vite-plugin-dynamic-import: "npm:^1.5.0" languageName: unknown linkType: soft @@ -5255,6 +5272,18 @@ __metadata: languageName: node linkType: hard +"vite-plugin-dynamic-import@npm:^1.5.0": + version: 1.5.0 + resolution: "vite-plugin-dynamic-import@npm:1.5.0" + dependencies: + acorn: "npm:^8.8.2" + es-module-lexer: "npm:^1.2.1" + fast-glob: "npm:^3.2.12" + magic-string: "npm:^0.30.1" + checksum: 10c0/ad069da3be8b6cd730b028174ded3b97a810a3ad2171fe6e22d5623d57b07af94a81e8b0c994f26b4b43e7ffa0d99bb34ebc392a9ae8e4fc39bc2bc9c49e63cf + languageName: node + linkType: hard + "vite@npm:^5.2.0": version: 5.2.11 resolution: "vite@npm:5.2.11"