facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.85k stars 630 forks source link

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

Open ayroblu opened 8 months ago

ayroblu commented 8 months ago

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

ayroblu commented 6 months ago

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")
pascalduez commented 3 months ago

Hello,

just hit the exact same issue :)