mirror of
https://gitee.com/openharmony/third_party_weex-loader
synced 2024-11-23 07:20:51 +00:00
commit
be9468773b
@ -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) {
|
||||
|
@ -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
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user