Skip to content

shinout/babel-register-with-upper-dir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel/babel#7701

This repo is for bug reproduction, an issue with @babel/register applied with monorepo-structured packages using Yarn Workspaces.

How to reproduce

yarn
yarn test

If you can see the following error message, it's reproducted.

/path/to/babel-register-with-upper-dir/packages/pkg-b/index.js:1
(function (exports, require, module, __filename, __dirname) { export default { name: 'pkg-b'  }
                                                              ^^^^^^
SyntaxError: Unexpected token export

Description

monorepo structure

├── node_modules
│   ├── pkg-a -> ../packages/pkg-a
│   ├── pkg-b -> ../packages/pkg-b
│   ...
├── README.md
├── package.json
├── packages
│   ├── pkg-a
│   │   ├── index.js
│   │   ├── package.json
│   │   └── test.js
│   └── pkg-b
│       ├── index.js
│       └── package.json
└── yarn.lock
  • packages contains two workspaces. pkg-a and pkg-b.
  • pkg-a depends on pkg-b.
  • All packages are located on node_modules at the project root.
  • pkg-a and pkg-b are also symlinked at node_modules at the project root.
  • A test is written using mocha at pkg-a.
  • mocha is passed --compiler js:@babel/register option.
  • As pkg-a uses pkg-b, pkg-b/index.js will be imported at the test.
  • Then, pkg-b/index.js cannot be applied babel. This is an unexpected behavior.
  • At .babelrc, only option is specified and pkg-b should be the target.

About

Bug reproduction environment for @babel/register

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published