Commit 70ccc780 by 张立顺

fix: restore mini-program script compatibility

1 parent 47fc03fc
......@@ -123,7 +123,7 @@
"useCompilerPlugins": [
"sass"
],
"ignoreDevUnusedFiles": false,
"ignoreDevUnusedFiles": true,
"ignoreUploadUnusedFiles": true,
"compileWorklet": false,
"uglifyFileName": false,
......
......@@ -18,7 +18,7 @@
"useLanDebug": false,
"showES6CompileOption": false,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": false,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": true
}
}
......@@ -29,7 +29,7 @@ function filterSpecificationList(specificationList, specificationKeys) {
const allowedValuesByIndex = specificationKeys.reduce(
(allowedValues, specificationKey) => {
specificationKey.split(';~;').forEach((value, index) => {
allowedValues[index] ??= new Set()
if (!allowedValues[index]) allowedValues[index] = new Set()
allowedValues[index].add(value)
})
return allowedValues
......
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { describe, it } from 'node:test'
import { filterLowPriceSelectOrderCatalog } from '../services/lowPriceCatalogFilter.helpers.js'
const helperSource = readFileSync(
new URL('../services/lowPriceCatalogFilter.helpers.js', import.meta.url),
'utf8',
)
function single(testId, validMinSellPrice) {
return {
testId,
......@@ -27,6 +33,10 @@ function packageItem(testId, goodsList) {
}
describe('filterLowPriceSelectOrderCatalog', () => {
it('avoids logical assignment syntax unsupported by the mini-program loader', () => {
assert.doesNotMatch(helperSource, /\?\?=/)
})
it('keeps only single goods with minimum-price validation enabled', () => {
const enabled = single('enabled', 'Y')
const disabled = single('disabled', 'N')
......
......@@ -39,6 +39,21 @@ describe('小程序上传边界', () => {
}
})
it('开发编译只加载小程序依赖图中的文件', async () => {
const [projectConfig, privateConfig] = await Promise.all([
readFile(path.join(projectRoot, 'project.config.json'), 'utf8').then(
JSON.parse
),
readFile(
path.join(projectRoot, 'project.private.config.json'),
'utf8',
).then(JSON.parse)
])
assert.equal(projectConfig.setting?.ignoreDevUnusedFiles, true)
assert.equal(privateConfig.setting?.ignoreDevUnusedFiles, true)
})
it('上传会过滤未使用文件、源映射和重复 npm 产物', async () => {
const config = JSON.parse(
await readFile(path.join(projectRoot, 'project.config.json'), 'utf8')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!