MCPcopy
hub / github.com/vercel/next.js / copy_styled_jsx_assets

Function copy_styled_jsx_assets

packages/next/taskfile.js:49–65  ·  view source on GitHub ↗
(task, opts)

Source from the content-addressed store, hash-verified

47}
48
49export async function copy_styled_jsx_assets(task, opts) {
50 // we copy the styled-jsx types so that we can reference them
51 // in the next-env.d.ts file so it doesn't matter if the styled-jsx
52 // package is hoisted out of Next.js' node_modules or not
53 const styledJsxPath = dirname(require.resolve('styled-jsx/package.json'))
54 const typeFiles = glob.sync('*.d.ts', { cwd: styledJsxPath })
55 const outputDir = join(__dirname, 'dist/styled-jsx')
56 // Separate type files into different folders to avoid conflicts between
57 // dev dep `styled-jsx` and `next/dist/styled-jsx` for duplicated declare modules
58 const typesDir = join(outputDir, 'types')
59 await fs.mkdir(typesDir, { recursive: true })
60
61 for (const file of typeFiles) {
62 const content = await fs.readFile(join(styledJsxPath, file), 'utf8')
63 await fs.writeFile(join(typesDir, file), content)
64 }
65}
66
67const externals = {
68 // don't bundle caniuse-lite and baseline-browser-mapping data so users can

Callers

nothing calls this directly

Calls 6

mkdirMethod · 0.80
resolveMethod · 0.65
writeFileMethod · 0.65
dirnameFunction · 0.50
joinFunction · 0.50
readFileMethod · 0.45

Tested by

no test coverage detected