Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ant-app-builder

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ant-app-builder - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

31

lib/index.js

@@ -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()
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc