Commit 70ccc780 by 张立顺

fix: restore mini-program script compatibility

1 parent 47fc03fc
...@@ -123,7 +123,7 @@ ...@@ -123,7 +123,7 @@
"useCompilerPlugins": [ "useCompilerPlugins": [
"sass" "sass"
], ],
"ignoreDevUnusedFiles": false, "ignoreDevUnusedFiles": true,
"ignoreUploadUnusedFiles": true, "ignoreUploadUnusedFiles": true,
"compileWorklet": false, "compileWorklet": false,
"uglifyFileName": false, "uglifyFileName": false,
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"useLanDebug": false, "useLanDebug": false,
"showES6CompileOption": false, "showES6CompileOption": false,
"checkInvalidKey": true, "checkInvalidKey": true,
"ignoreDevUnusedFiles": false, "ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": true "bigPackageSizeSupport": true
} }
} }
...@@ -29,7 +29,7 @@ function filterSpecificationList(specificationList, specificationKeys) { ...@@ -29,7 +29,7 @@ function filterSpecificationList(specificationList, specificationKeys) {
const allowedValuesByIndex = specificationKeys.reduce( const allowedValuesByIndex = specificationKeys.reduce(
(allowedValues, specificationKey) => { (allowedValues, specificationKey) => {
specificationKey.split(';~;').forEach((value, index) => { specificationKey.split(';~;').forEach((value, index) => {
allowedValues[index] ??= new Set() if (!allowedValues[index]) allowedValues[index] = new Set()
allowedValues[index].add(value) allowedValues[index].add(value)
}) })
return allowedValues return allowedValues
......
import assert from 'node:assert/strict' import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { describe, it } from 'node:test' import { describe, it } from 'node:test'
import { filterLowPriceSelectOrderCatalog } from '../services/lowPriceCatalogFilter.helpers.js' import { filterLowPriceSelectOrderCatalog } from '../services/lowPriceCatalogFilter.helpers.js'
const helperSource = readFileSync(
new URL('../services/lowPriceCatalogFilter.helpers.js', import.meta.url),
'utf8',
)
function single(testId, validMinSellPrice) { function single(testId, validMinSellPrice) {
return { return {
testId, testId,
...@@ -27,6 +33,10 @@ function packageItem(testId, goodsList) { ...@@ -27,6 +33,10 @@ function packageItem(testId, goodsList) {
} }
describe('filterLowPriceSelectOrderCatalog', () => { 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', () => { it('keeps only single goods with minimum-price validation enabled', () => {
const enabled = single('enabled', 'Y') const enabled = single('enabled', 'Y')
const disabled = single('disabled', 'N') const disabled = single('disabled', 'N')
......
...@@ -39,6 +39,21 @@ describe('小程序上传边界', () => { ...@@ -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 () => { it('上传会过滤未使用文件、源映射和重复 npm 产物', async () => {
const config = JSON.parse( const config = JSON.parse(
await readFile(path.join(projectRoot, 'project.config.json'), 'utf8') 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!