!50 so信息保存

Merge pull request !50 from 卡哥/master
This commit is contained in:
openharmony_ci 2022-03-22 15:24:49 +00:00 committed by Gitee
commit be9468773b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 6 additions and 2 deletions

View File

@ -39,7 +39,7 @@ module.exports = function (source, map) {
if (log && log.length) {
logWarn(this, log)
}
parsed = parseRequireModule(parsed)
parsed = parseRequireModule(parsed, this.resourcePath);
if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH || process.env.DEVICE_LEVEL === 'card') {
const appName = process.env.abilityType === 'page' ? 'app.js' : `${process.env.abilityType}.js`
if (path.basename(this.resourcePath) !== appName) {

View File

@ -27,6 +27,7 @@ import {
} from 'source-map'
const { DEVICE_LEVEL } = require('./lite/lite-enum')
export const useOSFiles = new Set();
export function getNameByPath (resourcePath) {
return path.basename(resourcePath).replace(/\..*$/, '')
@ -270,7 +271,7 @@ function requireModule(moduleName) {
return target;
}
`
export function parseRequireModule (source) {
export function parseRequireModule (source, resourcePath) {
const requireMethod = process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE ? methodForLite : methodForOthers
source = `${source}\n${requireMethod}`
const requireReg = /require\(['"]([^()]+)['"]\)/g
@ -287,6 +288,9 @@ export function parseRequireModule (source) {
source = source.replace(requireReg, (item, item1) => {
if (libReg.test(item1)) {
item = `requireNapi("${item1.replace(libReg, '$1')}", true)`
if (resourcePath) {
useOSFiles.add(resourcePath);
}
}
return item
})