Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/jsx2mp-loader/src/script-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,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 `_rax-view@1.0.2@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) {
Expand Down