Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: @babel/[email protected] fails when exporting namespace #15940

@snitin315

Description

@snitin315

💻

  • Would you like to work on a fix?

How are you using Babel?

@rollup/plugin-babel

Input code

Building the following code with @babel/preset-typescript fails:

import type { Brand, NativeOrWebBrand } from './types';

namespace Platform {
  export type Name = 'web';
}

export { Platform };

with the following error:

Screenshot 2023-09-07 at 8 36 52 AM

However if I move the export to declaration itself, it builds successful:

import type { Brand, NativeOrWebBrand } from './types';

export namespace Platform {
  export type Name = 'web';
}

Configuration file name

.babelrc.js

Configuration

{
      presets: [
        ['@babel/preset-env', { modules: false }],
        '@babel/preset-typescript',
        ['@babel/preset-react', { runtime: 'automatic' }],
      ],
      plugins: [
        [
          '@babel/plugin-transform-runtime',
          {
            helpers: true,
            regenerator: true,
          },
        ],
        [
          'babel-plugin-styled-components',
          {
            displayName: true,
            pure: true,
            ssr: true,
          },
        ],
      ],
    },

Current and expected behavior

Currently it throws error with v7.22

It should not throw error like in v7.16

Environment

System:
    OS: macOS 13.4.1
  Binaries:
    Node: 20.2.0 - ~/.nvm/versions/node/v20.2.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.6 - ~/.nvm/versions/node/v20.2.0/bin/npm
  npmPackages:
    @babel/core: 7.22.15 => 7.22.15 
    @babel/plugin-transform-react-jsx: 7.22.15 => 7.22.15 
    @babel/plugin-transform-runtime: 7.22.15 => 7.22.15 
    @babel/preset-env: 7.22.15 => 7.22.15 
    @babel/preset-react: 7.22.15 => 7.22.15 
    @babel/preset-typescript: 7.22.15 => 7.22.15 
    @babel/runtime: 7.22.15 => 7.22.15 
    babel-jest: 29.6.1 => 29.6.1 
    babel-loader: 8.2.3 => 8.2.3 
    babel-plugin-module-resolver: 4.1.0 => 4.1.0 
    babel-plugin-styled-components: 1.12.0 => 1.12.0 
    jest: 29.6.1 => 29.6.1 
    metro-react-native-babel-preset: 0.76.7 => 0.76.7 
    react-native: 0.72.3 => 0.72.3

Possible solution

No response

Additional context

No response

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions