Skip to content

Commit 50a5b9a

Browse files
committed
handle undefined package info in jest-transform and webpack-plugin
1 parent 01f8b90 commit 50a5b9a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/jest-transform/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ const vanillaTransformer: Transformer = {
1919
};
2020
}
2121

22-
const { name: packageName } = getPackageInfo(options.config.rootDir);
22+
const packageInfo = getPackageInfo(options.config.rootDir);
2323

2424
const code = transformSync({
2525
source,
2626
filePath,
2727
rootPath: options.config.rootDir,
28-
packageName: packageName,
28+
packageName: packageInfo?.name,
2929
identOption: 'debug',
3030
});
3131

packages/webpack-plugin/src/loader.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ const defaultIdentifierOption = (
4949
export default function (this: LoaderContext, source: string) {
5050
const { identifiers } = loaderUtils.getOptions(this) as InternalLoaderOptions;
5151

52-
const { name } = getPackageInfo(this.rootContext);
52+
const packageInfo = getPackageInfo(this.rootContext);
5353

5454
const callback = this.async();
5555

5656
transform({
5757
source,
5858
filePath: this.resourcePath,
5959
rootPath: this.rootContext,
60-
packageName: name,
60+
packageName: packageInfo?.name,
6161
identOption: defaultIdentifierOption(this.mode, identifiers),
6262
})
6363
.then((code) => {

0 commit comments

Comments
 (0)