ant-app-builder
Advanced tools
Comparing version 1.2.7 to 1.2.8
@@ -24,5 +24,23 @@ | ||
const dirPath = FS.path.dirname(filePath) | ||
const regexp = /require\(['"](.+?)['"]\)/g | ||
// reqursive file "require" | ||
const requireFile = async function(baseDir, reqStr, exclude) { | ||
let reqPath = FS.path.join(baseDir, reqStr.slice(9,-2)) | ||
let reqFile = await FS.readFile(reqPath) | ||
let rx = new RegExp(reqStr.replace(/(\(|\))/g, "\\$1"), "i") | ||
code = code.replace(rx, reqFile) | ||
let requires = code.match(regexp) || [] | ||
if (exclude) { | ||
requires = requires.filter(i => exclude.indexOf(i)) | ||
} | ||
if (requires.length) { | ||
let reqDir = FS.path.dirname(reqPath) | ||
await Promise.all(requires.map(async item => requireFile(reqDir, item, requires))) | ||
} | ||
} | ||
// rollup.js | ||
const bundle = await rollup.rollup({ input: filePath }) | ||
const bundle = await rollup.rollup({ input: filePath, treeshake: false }) | ||
const { output } = await bundle.generate({ format: "esm" }) | ||
@@ -32,12 +50,7 @@ | ||
let code = output[0].code | ||
let regexp = /require\(['"](.+?)['"]\)/g | ||
let requires = code.match(regexp) || [] | ||
// loop all requires | ||
await Promise.all(requires.map(async item => requireFile(dirPath, item))) | ||
await Promise.all(requires.map(async item => { | ||
let requirePath = FS.path.join(dirPath, item.slice(9,-2)) | ||
let requireFile = await FS.readFile(requirePath) | ||
let rx = new RegExp(item.replace(/(\(|\))/g, "\\$1"), "i") | ||
code = code.replace(rx, requireFile) | ||
})) | ||
// fix paths to app public folder | ||
code = code.replace(/(['"])~\/(.+?)(['"])/g, `$1/app/${namespace}/${id}/$2$3`) | ||
@@ -44,0 +57,0 @@ |
{ | ||
"name": "ant-app-builder", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib", |
@@ -5,11 +5,11 @@ | ||
let srcDir = path.join(__dirname, "test/photoshop") | ||
let destDir = path.join(__dirname, "test/_build") | ||
let uglify = false | ||
let srcDir = path.join(__dirname, "temp/test") | ||
let destDir = path.join(__dirname, "temp/_build") | ||
let uglify = true | ||
let runIt = async() => { | ||
let b = await Build(srcDir, destDir, uglify) | ||
console.log(b) | ||
//console.log(b) | ||
} | ||
runIt() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47807
327