Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function functionName() {
return compose(map((tk, idx, iterable) => {
// apply only on valid positions
// (start of simple commands)
// if token can form the name of a function,
// type of token is changed from WORD to NAME
/* console.log(
tk._.maybeStartOfSimpleCommand,
tk.is('WORD'),
iterable.ahead(1) &&
iterable.ahead(1).is('OPEN_PAREN'),
iterable.ahead(2) &&
iterable.ahead(2).is('CLOSE_PAREN')
);*/
if (
tk._.maybeStartOfSimpleCommand &&
// generte request
let request: string
if (isClassical) {
request = `!${minaLoader}?${JSON.stringify(
minaLoaderOptions
)}!${virtualMinaLoader}?${JSON.stringify({
extensions,
})}!${relativeRealRequest}`
} else {
request = relativeRealRequest
}
// entry name for SingleEntryPlugin
// `../../path/to/comp` => `_/_/path/to/comp`
const name = compose(
ensurePosix,
// FIXME: replace-ext will remove the leading `./` in path
// see https://github.com/gulpjs/replace-ext/issues/5
path => replaceExt(path, '.js'),
urlToRequest,
toSafeOutputPath
)(relativeRealPath)
// skip existing entries
const existingEntry = entries.find(item => item.request === request)
if (existingEntry) {
if (parentEntry) {
existingEntry.parents.push(parentEntry)
}
return
}
const originalRequest = loaderUtils.getRemainingRequest(this)
const filePath = this.resourcePath
let relativePath = path.relative(this.rootContext, filePath)
// move some files into subpackages
// .js files are moved in entry plugin but .json/.wxss/.wxml should be handled here
// @ts-ignore
const subpackageMapping: Record = this.subpackageMapping || {}
const entryName = replaceExt(helpers.toSafeOutputPath(relativePath), '')
if (subpackageMapping[entryName]) {
relativePath = subpackageMapping[entryName] + '.mina'
}
const dirname = compose(
ensurePosix,
helpers.toSafeOutputPath,
path.dirname
)(relativePath)
getBlocks(this, originalRequest)
.then(blocks =>
Promise.all(
[...TAGS_FOR_FILE_LOADER, ...TAGS_FOR_OUTPUT].map(async (tag: Tag) => {
let result: BlockResult = {
tag,
content: DEFAULT_CONTENT_OF_TAG[tag],
}
if (
!blocks[tag] ||
let resolve = (target: string) =>
compose(
ensurePosix,
helpers.toSafeOutputPath,
stripExt
)(resolveFromModule(context, target))