Skip to content

Why preset-react uses unexisted React.createElement when runtime is classic? #16027

Closed Answered by krutoo
krutoo asked this question in Q&A
Discussion options

You must be logged in to vote

I use custom transformation after build that looks like:

import fs from 'node:fs/promises';
import glob from 'fast-glob';

async function prependFile(path, content) {
  const data = await fs.readFile(path);
  const handle = await fs.open(path, 'w+');
  const insert = Buffer.from(content);

  await handle.write(insert, 0, insert.length, 0);
  await handle.write(data, 0, data.length, insert.length);
  await handle.close();
}

const react = `import * as React from 'react';\n`;

glob('./dist/esm/**/*.js')
  .then(items =>
    Promise.all(
      items.map(item => fs.readFile(item, 'utf-8').then(content => ({ filename: item, content }))),
    ),
  )
  .then(files => files.filter(item => item.co…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@krutoo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by krutoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants