facebook / hermes

A JavaScript engine optimized for running React Native.

Home Page:https://hermesengine.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-syntax-hermes-parser drops chunk names

ayroblu opened this issue · comments

Bug Description

In our babel config, we define:

...
plugins: [
  'babel-plugin-syntax-hermes-parser',
  ...
]
...

We also have this in our webpack build:

...
splitChunks: {
  cacheGroups: {
    shared: {
      name: (module, chunks, cacheGroupKey) => {
        return `${cacheGroupKey}~${chunks
          .map((chunk) => chunk.name)
          .join('~')}`.slice(0, 109);
      },
      ...
    },
    ...
  },
  ...
}

If I add a log on the names generated, BEFORE: shared~chunkname~otherchunkname AFTER: shared~~.

The only change I'm making to our codebase is to add the plugin to the babel.config.js

The parser should not drop chunk names

I figured out the basic issue, which is that the babel parser preserves comments, but the hermes parser doesn't

import( /* webpackChunkName: 'chunk.name' */ "./file");
import("./file")