Skip to content

Commit

Permalink
fix(chore): replace unpkg with npmmirror (opentiny#149)
Browse files Browse the repository at this point in the history
* fix(chore): replace unpkg with npmmirror

* fix(dev): dev environment use node_moduels

* fix(chore): sync version

* fix(preview): use npmmirror link

* fix(preview): devtoolapi use unpkg link

* fix(preview): import map add esm cdn

* fix(version): fix tiny-vue version

* fix(version): fix tiny-vue version

* fix(version): fix tiny-vue version
  • Loading branch information
chilingling authored Dec 15, 2023
1 parent 1d4c32e commit 11e302f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/design-core/canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://unpkg.com/@opentiny/vue-theme@3/index.css" rel="stylesheet" />
<link href="https://registry.npmmirror.com/@opentiny/vue-theme/3.10/files/index.css" rel="stylesheet" />
<style type="text/css">
.loading-warp {
display: flex;
Expand Down
2 changes: 2 additions & 0 deletions packages/design-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"@opentiny/tiny-engine-webcomponent-core": "workspace:^1.0.0",
"@opentiny/vue": "~3.10.0",
"@opentiny/vue-design-smb": "~3.10.0",
"@opentiny/vue-renderless": "~3.10.0",
"@opentiny/vue-theme": "~3.10.0",
"@vue/babel-plugin-jsx": "1.1.1",
"@vue/repl": "^1.3.0",
Expand All @@ -97,6 +98,7 @@
"xlsx": "^0.18.5"
},
"devDependencies": {
"@opentiny/tiny-engine-i18n-host": "workspace:*",
"@babel/eslint-parser": "^7.21.3",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@esbuild-plugins/node-modules-polyfill": "^0.2.2",
Expand Down
37 changes: 19 additions & 18 deletions packages/design-core/src/preview/src/preview/importMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,30 @@ const importMap = {}

const tinyVue3Imports = {
// 推荐之后统一使用@opentiny/vue去引入依赖,兼容后续录入的组件来源于tiny-vue
'@opentiny/vue': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue.mjs',
'@opentiny/vue-icon': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-icon.mjs',
'@opentiny/vue-common': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-common.mjs',
'@opentiny/vue-locale': 'https://unpkg.com/@opentiny/vue@3/runtime/tiny-vue-locale.mjs',
'@opentiny/vue-renderless/': 'https://unpkg.com/@opentiny/vue-renderless@3/'
'@opentiny/vue': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue.mjs',
'@opentiny/vue-icon': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-icon.mjs',
'@opentiny/vue-common': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-common.mjs',
'@opentiny/vue-locale': 'https://registry.npmmirror.com/@opentiny/vue/3.11/files/runtime/tiny-vue-locale.mjs',
'@opentiny/vue-renderless/': 'https://esm.sh/@opentiny/vue-renderless@3.11/?raw'
}

importMap.imports = {
vue: 'https://unpkg.com/[email protected]/dist/vue.runtime.esm-browser.js',
'vue/server-renderer': 'https://unpkg.com/@vue/[email protected]/dist/server-renderer.esm-browser.js',
'vue-i18n': 'https://unpkg.com/[email protected]/dist/vue-i18n.esm-browser.js',
'vue-router': 'https://unpkg.com/[email protected]/dist/vue-router.esm-browser.js',
'@vue/devtools-api': 'https://unpkg.com/@vue/[email protected]/lib/esm/index.js',
'@vueuse/core': 'https://unpkg.com/@vueuse/[email protected]/index.mjs',
'@vueuse/shared': 'https://unpkg.com/@vueuse/[email protected]/index.mjs',
axios: 'https://unpkg.com/[email protected]/dist/esm/axios.js',
'axios-mock-adapter': 'https://unpkg.com/[email protected]/dist/axios-mock-adapter.js',
vue: 'https://registry.npmmirror.com/vue/3.2.36/files/dist/vue.esm-browser.js',
'vue/server-renderer':
'https://registry.npmmirror.com/vue/server-renderer/3.2.36/files/dist/server-renderer.esm-browser.js',
'vue-i18n': 'https://registry.npmmirror.com/vue-i18n/9.2.0/files/dist/vue-i18n.esm-browser.js',
'vue-router': 'https://registry.npmmirror.com/vue-router/4.0.16/files/dist/vue-router.esm-browser.js',
'@vue/devtools-api': 'https://esm.sh/@vue/[email protected]/lib/esm/index.js?raw',
'@vueuse/core': 'https://registry.npmmirror.com/@vueuse/core/9.6.0/files/index.mjs',
'@vueuse/shared': 'https://registry.npmmirror.com/@vueuse/shared/9.6.0/files/index.mjs',
axios: 'https://registry.npmmirror.com/axios/1.0.0-alpha.1/files/dist/esm/axios.js',
'axios-mock-adapter': 'https://registry.npmmirror.com/axios-mock-adapter/1.21.1/files/dist/axios-mock-adapter.js',
'@opentiny/tiny-engine-webcomponent-core':
'https://unpkg.com/@opentiny/tiny-engine-webcomponent-core@1/dist/tiny-engine-webcomponent-core.es.js',
'https://registry.npmmirror.com/@opentiny/tiny-engine-webcomponent-core/1/files/dist/tiny-engine-webcomponent-core.es.js',
'@opentiny/tiny-engine-i18n-host':
'https://unpkg.com/@opentiny/tiny-engine-i18n-host@1/dist/tiny-engine-i18n-host.es.js',
'vue-demi': 'https://unpkg.com/vue-demi@0.13.11/lib/index.mjs',
pinia: 'https://unpkg.com/pinia@2.0.22/dist/pinia.esm-browser.js',
'https://registry.npmmirror.com/@opentiny/tiny-engine-i18n-host/1/files/dist/tiny-engine-i18n-host.es.js',
'vue-demi': 'https://registry.npmmirror.com/vue-demi/0.13.11/files/lib/index.mjs',
pinia: 'https://registry.npmmirror.com/pinia/2.0.22/files/dist/pinia.esm-browser.js',
...tinyVue3Imports,
...getSearchParams().scripts
}
Expand Down
24 changes: 12 additions & 12 deletions packages/design-core/src/preview/src/preview/srcFiles/app.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

function addCss(href) {
const link = document.createElement('link')
link.setAttribute('rel', 'stylesheet')
link.setAttribute('href', href)
document.head.appendChild(link)
}
addCss('https://unpkg.com/@opentiny/vue-theme@3/index.css')
addCss('https://unpkg.com/@opentiny/vue-theme-mobile@3/index.css')
addCss('https://registry.npmmirror.com/@opentiny/vue-theme/3.10/files/index.css')
addCss('https://registry.npmmirror.com/@opentiny/vue-theme-mobile/3.10/files/index.css')
10 changes: 7 additions & 3 deletions packages/design-core/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const config = {
const importMapVersions = {
prettier: '2.7.1',
vue: '3',
tinyVue: '3'
tinyVue: '~3.11'
}

const devAlias = {
Expand Down Expand Up @@ -177,7 +177,7 @@ const devAlias = {

const devVueAlias = {
find: /^vue$/,
replacement: `https://unpkg.com/vue@${importMapVersions.vue}/dist/vue.runtime.esm-browser.js`
replacement: `https://registry.npmmirror.com/vue/${importMapVersions.vue}/files/dist/vue.runtime.esm-browser.js`
}

const prodAlias = {
Expand Down Expand Up @@ -270,7 +270,11 @@ export default defineConfig(({ command, mode }) => {
}
}

config.plugins.push(monacoEditorPluginInstance, htmlPlugin(mode), importmapPlugin(importmap, importMapStyles))
config.plugins.push(
monacoEditorPluginInstance,
htmlPlugin(mode),
command === 'build' && importmapPlugin(importmap, importMapStyles)
)

return config
})

0 comments on commit 11e302f

Please sign in to comment.