Repository: parcel-bundler/parcel
File: packages/core/integration-tests/test/transpilation.js (JavaScript)

Code before:

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('react/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with preact >= 10.5', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-automatic-preact/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('preact/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with preact with alias', async function () {
    let b = await bundle(
      path.join(
        __dirname,
        '/integration/jsx-automatic-preact-with-alias/index.js',
      ),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with explicit tsconfig.json', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-automatic-tsconfig/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('preact/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support explicit JSX pragma in tsconfig.json', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-pragma-tsconfig/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('JSX(JSXFragment'));
    assert(file.includes('JSX("div"'));
  });

  it('should support explicitly enabling JSX in tsconfig.json', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-tsconfig/index.js'),

Review comment (suggestion):
I think we should also add this to make sure it's actually importing from React (using a Regex because `react/jsx-runtime` is a substring of `preact/jsx-runtime`).

```suggestion
    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(/\Wreact\/jsx-runtime\W/.test(file));
    assert(file.includes('_jsxRuntime.jsx("div"'));
```

Code after:

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('react/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with preact >= 10.5', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-automatic-preact/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('preact/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with preact with alias', async function () {
    let b = await bundle(
      path.join(
        __dirname,
        '/integration/jsx-automatic-preact-with-alias/index.js',
      ),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(/\Wreact\/jsx-runtime\W/.test(file));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support the automatic JSX runtime with explicit tsconfig.json', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-automatic-tsconfig/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('preact/jsx-runtime'));
    assert(file.includes('_jsxRuntime.jsx("div"'));
  });

  it('should support explicit JSX pragma in tsconfig.json', async function () {
    let b = await bundle(
      path.join(__dirname, '/integration/jsx-pragma-tsconfig/index.js'),
    );

    let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
    assert(file.includes('JSX(JSXFragment'));
    assert(file.includes('JSX("div"'));
  });

  it('should support explicitly enabling JSX in tsconfig.json', async function () {
    let b = await bundle(