๐Ÿ’ป์šฉ๋‡ฝ ๊ฐœ๋ฐœ ๋…ธํŠธ๐Ÿ’ป
article thumbnail
๋ฐ˜์‘ํ˜•

๐Ÿ“– ๋“ค์–ด๊ฐ€๋ฉฐ

Next.js 13 ๋ฒ„์ „ ์ดํ›„์—๋Š” Rust ์–ธ์–ด๋กœ ๊ฐœ๋ฐœ๋œ Turbopack์ด ๋„์ž…๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

ํ„ฐ๋ณดํŒฉ ์„ฑ๋Šฅ

Next 14 ๋ฒ„์ „์œผ๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์„ ์ง„ํ–‰ํ•˜๊ณ  Turbopack์œผ๋กœ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์‹คํ–‰ํ–ˆ์„ ๋•Œ ๋งž์ดํ•œ ๋ฌธ์ œ์— ๋Œ€ํ•ด์„œ ์ •๋ฆฌํ•ด๋ณด๋ ค ํ•ฉ๋‹ˆ๋‹ค.

๋ฌธ์ œ ๋ฐœ์ƒ โ—

Turbopack์œผ๋กœ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์‹คํ–‰ํ•˜์ž ์•„๋ž˜์™€ ๊ฐ™์ด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.

Element type is invalid: expected a string

 

์ด ์˜ค๋ฅ˜์— ๋Œ€ํ•ด ๊ฒ€์ƒ‰ํ•ด ๋ณด๋‹ˆ "์ปดํฌ๋„ŒํŠธ์˜ ์ด๋ฆ„์ด ์ž˜๋ชป๋˜์—ˆ๊ฑฐ๋‚˜, import ๊ฒฝ๋กœ๊ฐ€ ์ž˜๋ชป ์ž…๋ ฅ๋˜์—ˆ์„ ๋•Œ ๋ฐœ์ƒํ•œ๋‹ค"๋Š” ์„ค๋ช…์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์ด์— ๋”ฐ๋ผ import ๋œ ๋ถ€๋ถ„์„ ์ž˜ ํ™•์ธํ•ด ๋ณด๋ผ๋Š” ์กฐ์–ธ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋Ÿฌ๋‚˜, ์ œ ์ฝ”๋“œ์—์„œ๋Š” import๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ด๋ฃจ์–ด์กŒ๊ธฐ ๋•Œ๋ฌธ์— ์ˆ˜์ •ํ•  ๋ถ€๋ถ„์ด ์—†์—ˆ์Šต๋‹ˆ๋‹ค.

 

๋”ฐ๋ผ์„œ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€๋ฅผ ๋‹ค์‹œ ํ™•์ธํ•ด ๋ณธ ๊ฒฐ๊ณผ 'DarkModeBtn' ์ปดํฌ๋„ŒํŠธ์—์„œ ๋ฐœ์ƒํ–ˆ์Œ์„ ์•Œ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์ด์— ๋”ฐ๋ผ DarkModeBtn์ด import ๋œ ๋ถ€๋ถ„์„ ์ฃผ์„ ์ฒ˜๋ฆฌํ•ด ๋ณด์•˜๊ณ , ์ด๋กœ ์ธํ•ด ์—๋Ÿฌ๊ฐ€ ์‚ฌ๋ผ์กŒ์Œ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

๋” ์ž์„ธํžˆ ์‚ดํŽด๋ณธ ๊ฒฐ๊ณผ, DarkModeBtn ์ปดํฌ๋„ŒํŠธ์—์„œ svg๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์—ˆ๊ณ , Next.js์—์„œ svg๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€ ์„ค์ •์„ ํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋•Œ '@svgr/webpack'์„ ์‚ฌ์šฉํ•˜์—ฌ svg๋ฅผ ํ‘œํ˜„ํ•˜๊ณ  ์žˆ์—ˆ๊ณ , '@svgr/webpack'์— ๋Œ€ํ•œ ์„ค์ •๋„ next.config.js์—์„œ ์•„๋ž˜์™€ ๊ฐ™์ด ์ถ”๊ฐ€ํ•ด ๋’€์—ˆ์Šต๋‹ˆ๋‹ค.

webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    });

    return config;
  },

์ด๋Ÿฌํ•œ ์„ค์ •์€ webpack์— ๋งž์ถฐ์ง„ ๊ฒƒ์ด์—ˆ๊ธฐ์—, Turbopack์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค๊ณ  ์ถ”์ •ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋ฌธ์ œ ํ•ด๊ฒฐ โœ…

์ด ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ์ฑ…์„ ์ฐพ์•„๋ณด๋˜ ์ค‘, ๋‹คํ–‰ํžˆ๋„ next.js์™€ turbo์˜ github์—์„œ ๋™์ผํ•œ ์ด์Šˆ๋ฅผ ๊ฒช๊ณ  ์žˆ๋Š” ์‚ฌ๋žŒ๋“ค์˜ ๊ธ€์„ ๋ฐœ๊ฒฌํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

https://github.com/vercel/turbo/issues/4832

 

[turbopack] SVG via svgr support · Issue #4832 · vercel/turbo

What version of Turborepo are you using? next@13.4.1 What package manager are you using / does the bug impact? npm What operating system are you using? Mac Describe the Bug In Next.js, I use the SV...

github.com

https://github.com/vercel/next.js/issues/48140

 

App fails to build with Turbopack loader · Issue #48140 · vercel/next.js

Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Versi...

github.com

์œ„ ์ด์Šˆ๋“ค์„ ์ฐธ์กฐํ•˜์—ฌ ํ˜„์žฌ ํ”„๋กœ์ ํŠธ์˜ next.config.js์— ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

module.exports = {
  // output: 'export',
  reactStrictMode: true,
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/,
      use: ['@svgr/webpack'],
    });

    return config;
  },
  compiler: {
    // ssr and displayName are configured by default
    styledComponents: true,
  },
  // ์ถ”๊ฐ€๋œ ๋ถ€๋ถ„
  experimental: {
    turbo: {
      rules: {
        '*.svg': {
          loaders: ['@svgr/webpack'],
          as: '*.js',
        },
      },
    },
  },
};

์ด๋ ‡๊ฒŒ Turbopack์„ ์œ„ํ•œ ์ถ”๊ฐ€ ์„ค์ •์„ ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค.

 

next dev --turbo๋กœ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ์‹คํ–‰ํ•˜๋‹ˆ ์˜ค๋ฅ˜๊ฐ€ ์‚ฌ๋ผ์กŒ์Šต๋‹ˆ๋‹ค.

์–ป์€ ์ ๐Ÿ“•

Next.js 13 ๋ฒ„์ „ ์ดํ›„์— ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋“ค์— ๋Œ€ํ•ด ์ฐธ๊ณ  ์ž๋ฃŒ๊ฐ€ ๋งŽ์ง€ ์•Š์•„, ์ฃผ๋กœ Github ์ด์Šˆ๋‚˜ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์ฐธ๊ณ ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฐ ์Šต๊ด€์ด ๊ธฐ๋ฅด๊ฒŒ ๋˜๋Š” ์œ ์ตํ•œ ๊ฒฝํ—˜์ธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๋ฐ˜์‘ํ˜•
profile

๐Ÿ’ป์šฉ๋‡ฝ ๊ฐœ๋ฐœ ๋…ธํŠธ๐Ÿ’ป

@์šฉ๋‡ฝ

ํฌ์ŠคํŒ…์ด ์ข‹์•˜๋‹ค๋ฉด "์ข‹์•„์š”โค๏ธ" ๋˜๋Š” "๊ตฌ๋…๐Ÿ‘๐Ÿป" ํ•ด์ฃผ์„ธ์š”!