Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@babel/register does not load custom plugins when cached #10081

Open
ykadosh opened this issue Jun 11, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@ykadosh
Copy link

commented Jun 11, 2019

Bug Report

Current Behavior
I'm running babel via @babel/register. In the configuration, I load a custom plugin that I wrote.
When I run babel for the first time (there's no cache) - the plugin is loaded properly. However the next time I run babel (which is now operating with some cache) it doesn't load the plugin.
Deleting node_modules/.cache fixes it, but then the next time I run it it fails again.

Input Code

require('@babel/register')({
  babelrcRoots: true,
  only: [...],
  plugins: [
    resolve(__dirname, './path/to/my/plugin'),
  ],
});

My Plugin

console.log('required\n');
module.exports = () => ({
  name: 'my-plugin',
  pre: () => {
    console.log('loaded\n');
  },
  visitor: {
    ImportDeclaration: {
      enter(path) {
        console.log('parsed\n');
      },
    },
  },
});

Expected behavior/code
All log statements should be executed every time babel is run.

Babel Configuration (.babelrc, package.json, cli command)

module.exports = {
  presets: ['@babel/preset-env', '@babel/preset-react'],
  plugins: [
    '@babel/plugin-proposal-export-default-from',
    '@babel/plugin-proposal-function-bind',
    '@babel/plugin-transform-runtime',
    ['@babel/plugin-proposal-decorators', {'legacy': true}],
    ['@babel/plugin-proposal-class-properties', {'loose': true}],
    [
      'module-resolver',
      {
        'cwd': 'babelrc',
        'root': ['./'],
        'alias': {...},
      },
    ],
  ]
};

Environment

  • Babel version(s): 7.4.0
  • Node 10.15.1/npm 6.4.1
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: register
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Jun 11, 2019

Hey @ykadosh! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@ykadosh ykadosh changed the title babel-register does not load plugins when cached babel-register does not load custom plugins when cached Jun 12, 2019

@ykadosh ykadosh changed the title babel-register does not load custom plugins when cached @babel/register does not load custom plugins when cached Jun 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.