Skip to content

Commit

Permalink
wip: uni_modules 编译模式
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Apr 30, 2024
1 parent 7ce57d4 commit f56f519
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 109 deletions.
186 changes: 80 additions & 106 deletions packages/playground/__tests__/__snapshots__/uni_modules.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,116 +1,90 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`uni_modules playground uni-app-x build:app-ios 1`] = `
"import Logo from "./test-com1/components/test-com1-1/logo.png";
import { openBlock, createElementBlock, Fragment, createElementVNode, toDisplayString } from "vue";
import _export_sfc from "plugin-vue:export-helper";
const _sfc_main$1 = {
data() {
return {
msg: "test-com1-1",
logo: Logo
};
}
};
"import { defineComponent, openBlock, createElementBlock, Fragment, createElementVNode, toDisplayString } from 'vue';
import Logo from './test-com1/components/test-com1-1/logo.png';
import _export_sfc from 'plugin-vue:export-helper';
const _sfc_main$1 = defineComponent({
data() {
return {
msg: 'test-com1-1',
logo: Logo
};
}
});
const _style_0$1 = {"text":{"":{"color":"#FF0000"}}};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock(Fragment, null, [
createElementVNode("text", { class: "text" }, toDisplayString($data.msg) + toDisplayString($data.logo), 1),
createElementVNode("image", { src: Logo })
], 64);
}
const testCom11 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const _sfc_main = {
data() {
return {
msg: "test-com1-2",
logo: Logo
};
}
};
const testCom11 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["styles", [_style_0$1]]]);
const _sfc_main = defineComponent({
data() {
return {
msg: 'test-com1-2',
logo: Logo
};
}
});
const _style_0 = {"text2":{"":{"color":"#FF0000"}}};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock(Fragment, null, [
createElementVNode("text", { class: "text2" }, toDisplayString($data.msg) + toDisplayString($data.logo), 1),
createElementVNode("image", { src: Logo })
], 64);
}
const testCom12 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
testCom11 as TestCom11,
testCom12 as TestCom12
};
const testCom12 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]]]);
export { testCom11 as TestCom11, testCom12 as TestCom12 };
"
`;

exports[`uni_modules playground uni-app-x build:app-ios 2`] = `
"import Logo from "./test-com2/components/test-com2-1/logo.png";
import { openBlock, createElementBlock, toDisplayString } from "vue";
import _export_sfc from "plugin-vue:export-helper";
const _sfc_main$1 = {
data() {
return {
msg: "test-com2-1",
logo: Logo
};
}
};
"import { defineComponent, openBlock, createElementBlock, toDisplayString } from 'vue';
import Logo from './test-com2/components/test-com2-1/logo.png';
import _export_sfc from 'plugin-vue:export-helper';
const _sfc_main$1 = defineComponent({
data() {
return {
msg: 'test-com2-1',
logo: Logo
};
}
});
const _style_0$1 = {"text":{"":{"color":"#FF0000"}}};
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("text", { class: "text" }, toDisplayString($data.msg) + toDisplayString($data.logo), 1);
}
const testCom21 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
const _sfc_main = {
data() {
return {
msg: "test-com2-2",
logo: Logo
};
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("text", { class: "text2" }, toDisplayString($data.msg) + toDisplayString($data.logo), 1);
}
const testCom22 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
testCom21 as TestCom21,
testCom22 as TestCom22
};
"
`;
const testCom21 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["styles", [_style_0$1]]]);
exports[`uni_modules playground uni-app-x build:app-ios 3`] = `
"
.text {
color: red;
}
.image {
background: url('@/uni_modules/test-com1/components/test-com1-1/logo.png');
}
"
`;
const _sfc_main = defineComponent({
data() {
return {
msg: 'test-com2-2',
logo: Logo
};
}
});
exports[`uni_modules playground uni-app-x build:app-ios 4`] = `
"
.text2 {
color: red;
}
"
`;
const _style_0 = {"text2":{"":{"color":"#FF0000"}}};
exports[`uni_modules playground uni-app-x build:app-ios 5`] = `
"
.text {
color: red;
}
.image {
background: url('@/uni_modules/test-com2/components/test-com2-1/logo.png');
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("text", { class: "text2" }, toDisplayString($data.msg) + toDisplayString($data.logo), 1);
}
"
`;
const testCom22 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["styles", [_style_0]]]);
exports[`uni_modules playground uni-app-x build:app-ios 6`] = `
"
.text2 {
color: red;
}
export { testCom21 as TestCom21, testCom22 as TestCom22 };
"
`;

Expand All @@ -119,17 +93,17 @@ exports[`uni_modules playground uni-app-x build:h5 1`] = `
import { Text, Image } from "@dcloudio/uni-h5";
import "@dcloudio/uni-components/style/image.css";
import "@dcloudio/uni-components/style/resize-sensor.css";
import { defineComponent, openBlock, createElementBlock, Fragment, createVNode, withCtx, createTextVNode, toDisplayString } from "vue";
import Logo from "./test-com1/components/test-com1-1/logo.png";
import { openBlock, createElementBlock, Fragment, createVNode, withCtx, createTextVNode, toDisplayString } from "vue";
import _export_sfc from "plugin-vue:export-helper";
const _sfc_main$1 = {
const _sfc_main$1 = defineComponent({
data() {
return {
msg: "test-com1-1",
logo: Logo
};
}
};
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_v_uni_text = Text;
const _component_v_uni_image = Image;
Expand All @@ -143,15 +117,15 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
createVNode(_component_v_uni_image, { src: Logo })
], 64);
}
const testCom11 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-a4ecbcc3"]]);
const _sfc_main = {
const testCom11 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-14e59d16"]]);
const _sfc_main = defineComponent({
data() {
return {
msg: "test-com1-2",
logo: Logo
};
}
};
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_v_uni_text = Text;
const _component_v_uni_image = Image;
Expand All @@ -165,7 +139,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
createVNode(_component_v_uni_image, { src: Logo })
], 64);
}
const testCom12 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-4d21cdc3"]]);
const testCom12 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-3c9048c8"]]);
export {
testCom11 as TestCom11,
testCom12 as TestCom12
Expand All @@ -176,17 +150,17 @@ export {
exports[`uni_modules playground uni-app-x build:h5 2`] = `
"import "@dcloudio/uni-components/style/text.css";
import { Text } from "@dcloudio/uni-h5";
import { defineComponent, openBlock, createBlock, withCtx, createTextVNode, toDisplayString } from "vue";
import Logo from "./test-com2/components/test-com2-1/logo.png";
import { openBlock, createBlock, withCtx, createTextVNode, toDisplayString } from "vue";
import _export_sfc from "plugin-vue:export-helper";
const _sfc_main$1 = {
const _sfc_main$1 = defineComponent({
data() {
return {
msg: "test-com2-1",
logo: Logo
};
}
};
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_v_uni_text = Text;
return openBlock(), createBlock(_component_v_uni_text, { class: "text" }, {
Expand All @@ -196,15 +170,15 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
_: 1
});
}
const testCom21 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-f33122a3"]]);
const _sfc_main = {
const testCom21 = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__scopeId", "data-v-75bce91a"]]);
const _sfc_main = defineComponent({
data() {
return {
msg: "test-com2-2",
logo: Logo
};
}
};
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_v_uni_text = Text;
return openBlock(), createBlock(_component_v_uni_text, { class: "text2" }, {
Expand All @@ -214,7 +188,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
_: 1
});
}
const testCom22 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-ac423ad8"]]);
const testCom22 = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-6088c0cc"]]);
export {
testCom21 as TestCom21,
testCom22 as TestCom22
Expand All @@ -227,10 +201,10 @@ exports[`uni_modules playground uni-app-x build:h5 3`] = `
.text[data-v-a4ecbcc3] {
.text[data-v-14e59d16] {
color: red;
}
.image[data-v-a4ecbcc3] {
.image[data-v-14e59d16] {
background: url('@/uni_modules/test-com1/components/test-com1-1/logo.png');
}
"
Expand All @@ -241,7 +215,7 @@ exports[`uni_modules playground uni-app-x build:h5 4`] = `
.text2[data-v-4d21cdc3] {
.text2[data-v-3c9048c8] {
color: red;
}
"
Expand All @@ -250,10 +224,10 @@ exports[`uni_modules playground uni-app-x build:h5 4`] = `
exports[`uni_modules playground uni-app-x build:h5 5`] = `
"
.text[data-v-f33122a3] {
.text[data-v-75bce91a] {
color: red;
}
.image[data-v-f33122a3] {
.image[data-v-75bce91a] {
background: url('@/uni_modules/test-com2/components/test-com2-1/logo.png');
}
"
Expand All @@ -262,7 +236,7 @@ exports[`uni_modules playground uni-app-x build:h5 5`] = `
exports[`uni_modules playground uni-app-x build:h5 6`] = `
"
.text2[data-v-ac423ad8] {
.text2[data-v-6088c0cc] {
color: red;
}
"
Expand Down
10 changes: 7 additions & 3 deletions packages/playground/__tests__/uni_modules.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'fs'
import fs from 'fs-extra'
import path from 'path'
import execa from 'execa'
import { sync } from 'fast-glob'
Expand Down Expand Up @@ -32,13 +32,16 @@ describe('uni_modules playground', () => {
// 'build:mp-weixin',
],
}
const distDir = path.resolve(projectDir, 'dist')
if (fs.existsSync(distDir)) {
fs.emptyDirSync(distDir)
}
Object.keys(modes).forEach((mode) => {
const scripts = modes[mode]
scripts.forEach((script) => {
test(`${mode} ${script}`, async () => {
const outDir = path.resolve(
projectDir,
'dist',
distDir,
'build',
mode,
script.replace('build:', '')
Expand All @@ -49,6 +52,7 @@ describe('uni_modules playground', () => {
...process.env,
UNI_OUTPUT_DIR: outDir,
UNI_COMPILE_TARGET: 'uni_modules',
UNI_APP_X: mode === 'uni-app-x' ? 'true' : 'false',
},
})
sync('**/*', { cwd: outDir, absolute: true }).forEach((file) => {
Expand Down
1 change: 1 addition & 0 deletions packages/playground/uni_modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
},
"devDependencies": {
"@dcloudio/uni-cli-shared": "../../uni-cli-shared",
"@dcloudio/uni-uts-v1": "../../uni-uts-v1",
"@dcloudio/vite-plugin-uni": "../../vite-plugin-uni",
"vite": "^5.2.8"
},
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f56f519

Please sign in to comment.