From c6a0614d54e77c3c33f5f392c0e71b4b1bc121aa Mon Sep 17 00:00:00 2001 From: wangchun17 Date: Sun, 26 Sep 2021 18:31:26 +0800 Subject: [PATCH] chunn.wang@huawei.com Signed-off-by: wangchun17 Change-Id: Ic31122220b31a3648a4809358843c2744b66b81d --- src/loader.js | 7 ++----- src/script.js | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/loader.js b/src/loader.js index 1ca9b4d..359d404 100644 --- a/src/loader.js +++ b/src/loader.js @@ -181,7 +181,7 @@ function loader (source) { const isEntry = resourceQuery.entry const dirName = path.parse(this.resourcePath) const name = isEntry ? dirName.name : resourceQuery.name || getNameByPath(this.resourcePath) - if (isReservedTag(name)) { + if (isReservedTag(name) && process.env.abilityType === 'page') { logWarn(this, [{ reason: 'ERROR: The file name cannot contain reserved tag name: ' + name }]) @@ -195,10 +195,7 @@ function loader (source) { } function checkApp(_this) { - return ["app.js", "data.js", "service.js"].some(item => { - const type = item === "app.js" ? "page" : item === "data.js" ? "data" : item === "service.js" ? "service" : item; - return _this.resourcePath.indexOf(item) > 0 && process.env.abilityType === type - }) + return _this.resourcePath.indexOf(process.env.abilityType === 'page' ? 'app.js' : `${process.env.abilityType}.js`) > 0 } function loadApp (_this, name, isEntry, customLang) { diff --git a/src/script.js b/src/script.js index 5410b72..ad98551 100644 --- a/src/script.js +++ b/src/script.js @@ -41,7 +41,8 @@ module.exports = function (source, map) { } parsed = parseRequireModule(parsed) if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH) { - if (!["app.js","data.js","service.js"].includes(path.basename(this.resourcePath))) { + const appName = process.env.abilityType === 'page' ? 'app.js' : `${process.env.abilityType}.js` + if (path.basename(this.resourcePath) !== appName) { parsed += `\nvar moduleOwn = exports.default || module.exports;\nvar accessors = ['public', 'protected', 'private']; if (moduleOwn.data && accessors.some(function (acc) { return moduleOwn[acc]; -- Gitee