Sfoglia il codice sorgente

重构项目结构,移除旧的index.js,添加Vue组件和Rollup配置

zhuf 6 mesi fa
parent
commit
26e8901329
9 ha cambiato i file con 1285 aggiunte e 6 eliminazioni
  1. 1 0
      .gitignore
  2. 20 0
      dist/index-B-3llPgV.js
  3. 5 0
      dist/index.js
  4. 0 3
      index.js
  5. 16 3
      package.json
  6. 1205 0
      pnpm-lock.yaml
  7. 25 0
      rollup.config.js
  8. 3 0
      src/index.js
  9. 10 0
      src/index.vue

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+node_modules

+ 20 - 0
dist/index-B-3llPgV.js

@@ -0,0 +1,20 @@
+import { ref, openBlock, createElementBlock, toDisplayString } from 'vue';
+
+var script = {
+  __name: 'index',
+  setup(__props) {
+
+const count = ref(0);
+
+return (_ctx, _cache) => {
+  return (openBlock(), createElementBlock("button", {
+    onClick: _cache[0] || (_cache[0] = $event => (count.value++))
+  }, " Count is: " + toDisplayString(count.value), 1 /* TEXT */))
+}
+}
+
+};
+
+script.__file = "src/index.vue";
+
+export { script as default };

+ 5 - 0
dist/index.js

@@ -0,0 +1,5 @@
+import { defineAsyncComponent } from 'vue';
+
+var index = defineAsyncComponent(() => import('./index-B-3llPgV.js'));
+
+export { index as default };

+ 0 - 3
index.js

@@ -1,3 +0,0 @@
-export function sum(a, b) {
-  return a + b;
-}

+ 16 - 3
package.json

@@ -2,12 +2,25 @@
   "name": "utils",
   "version": "1.0.1",
   "description": "",
-  "main": "index.js",
+  "main": "dist/bundle.js",
   "type": "module",
   "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1"
+    "build": "rimraf dist && rollup -c"
   },
   "keywords": [],
   "author": "",
-  "license": "ISC"
+  "license": "ISC",
+  "devDependencies": {
+    "@rollup/plugin-babel": "^6.0.4",
+    "@rollup/plugin-commonjs": "^28.0.2",
+    "@rollup/plugin-json": "^6.1.0",
+    "@rollup/plugin-node-resolve": "^16.0.0",
+    "rimraf": "^6.0.1",
+    "rollup": "^4.28.1",
+    "rollup-plugin-vue": "^6.0.0",
+    "vue": "^3.5.13"
+  },
+  "peerDependencies": {
+    "vue": "^3.5.13"
+  }
 }

File diff suppressed because it is too large
+ 1205 - 0
pnpm-lock.yaml


+ 25 - 0
rollup.config.js

@@ -0,0 +1,25 @@
+import resolve from '@rollup/plugin-node-resolve';
+import commonjs from '@rollup/plugin-commonjs';
+import vue from 'rollup-plugin-vue';
+import babel from '@rollup/plugin-babel';
+import json from '@rollup/plugin-json';
+
+export default {
+  input: 'src/index.js', // 入口文件
+  output: {
+    dir: 'dist',
+    format: 'es', // 输出格式
+  },
+  plugins: [
+    resolve(),
+    commonjs(),
+    vue(),
+    babel({
+      exclude: 'node_modules/**',
+      babelHelpers: 'bundled'
+    }),
+    json(),
+  ],
+
+  external: ['vue'],
+};

+ 3 - 0
src/index.js

@@ -0,0 +1,3 @@
+import { defineAsyncComponent } from 'vue'
+
+export default defineAsyncComponent(() => import('./index.vue'))

+ 10 - 0
src/index.vue

@@ -0,0 +1,10 @@
+<script setup>
+import { ref } from 'vue'
+const count = ref(0)
+</script>
+
+<template>
+  <button @click="count++">
+    Count is: {{ count }}
+  </button>
+</template>