This commit is contained in:
61
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/index.js
generated
vendored
Normal file
61
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
function resolveNativeBinding () {
|
||||
const { platform, arch } = process
|
||||
let nativeBinding = ''
|
||||
switch (platform) {
|
||||
case 'win32':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
nativeBinding = 'preprocessor-windows-x86_64'
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
||||
}
|
||||
break
|
||||
case 'darwin':
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
nativeBinding = 'preprocessor-macos-x86_64'
|
||||
break
|
||||
case 'arm64':
|
||||
nativeBinding = 'preprocessor-macos-arm64'
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
||||
}
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
||||
}
|
||||
return require('./' + nativeBinding)
|
||||
}
|
||||
|
||||
async function runProcess (vue3 = false) {
|
||||
try {
|
||||
/* eslint-disable no-undef */
|
||||
globalThis.preprocessor_require = require
|
||||
await resolveNativeBinding().process(vue3)
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
class PreprocessorWebpackPlugin {
|
||||
apply (compiler) {
|
||||
compiler.hooks.afterEmit.tapPromise('d', (params) => {
|
||||
return runProcess(false)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function PreprocessorVitePlugin () {
|
||||
return {
|
||||
name: 'preprocessor',
|
||||
async writeBundle (_) {
|
||||
await runProcess(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
PreprocessorWebpackPlugin,
|
||||
PreprocessorVitePlugin
|
||||
}
|
||||
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-macos-arm64.node
generated
vendored
Normal file
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-macos-arm64.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-macos-x86_64.node
generated
vendored
Normal file
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-macos-x86_64.node
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-windows-x86_64.node
generated
vendored
Normal file
BIN
node_modules/@dcloudio/uni-cli-shared/lib/preprocessor/preprocessor-windows-x86_64.node
generated
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user