| 47 | } |
| 48 | |
| 49 | export 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 | |
| 67 | const externals = { |
| 68 | // don't bundle caniuse-lite and baseline-browser-mapping data so users can |