-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsx2mp-loader): 无法resolve的main字段不做修改
- Loading branch information
Showing
1 changed file
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,8 +174,13 @@ module.exports = function scriptLoader(content) { | |
|
||
const pkg = readJSONSync(sourcePackageJSONPath); | ||
const npmName = pkg.name; // Update to real npm name, for that tnpm will create like `[email protected]@rax-view` folders. | ||
const npmMainPath = join(sourcePackagePath, pkg.main || ''); | ||
|
||
let npmMainPath = join(sourcePackagePath, pkg.main || ''); | ||
try { | ||
// compat pkg.main without suffix like `lib/index` | ||
npmMainPath = require.resolve(npmMainPath); | ||
} catch (e) { | ||
// can't resolve npmMainPath | ||
} | ||
const isUsingMainMiniappComponent = pkg.hasOwnProperty(MINIAPP_CONFIG_FIELD) && this.resourcePath === npmMainPath; | ||
// Is miniapp compatible component. | ||
if (isUsingMainMiniappComponent || isRelativeMiniappComponent || isThirdMiniappComponent) { | ||
|