]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
build: improve size checks
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 20 Jul 2021 09:48:38 +0000 (11:48 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 20 Jul 2021 09:48:38 +0000 (11:48 +0200)
package.json
scripts/check-size.js
size-checks/option-store.js [moved from size-checks/small.js with 100% similarity]
size-checks/rollup.config.js
size-checks/setup-store.js [new file with mode: 0644]
yarn.lock

index 32156d46161a4e5d283383723a3c236fb94cbb50..edf321a72c63b1e4c6a80f9c6b6e3807ec92cf0d 100644 (file)
@@ -79,6 +79,7 @@
     "brotli": "^1.3.2",
     "codecov": "^3.8.2",
     "conventional-changelog-cli": "^2.1.1",
+    "globby": "^11.0.4",
     "jest": "^26.6.3",
     "jest-mock-warn": "^1.1.0",
     "lint-staged": "^11.0.1",
index 77439dcf24aa25ad22ba72304129915eb677c394..9ef1b04e6aed8650de9457f86984e3882a4e0302 100644 (file)
@@ -1,4 +1,5 @@
 const fs = require('fs')
+const globby = require('globby')
 const path = require('path')
 const chalk = require('chalk')
 const { gzipSync } = require('zlib')
@@ -21,4 +22,8 @@ function checkFileSize(filePath) {
   )
 }
 
-checkFileSize(path.resolve(__dirname, '../size-checks/dist/small.js'))
+const paths = globby.sync(path.resolve(__dirname, '../size-checks/dist/*.js'))
+
+for (const file of paths) {
+  checkFileSize(file)
+}
index b8ff9e67130387a8df31563719baf57957ae27ce..f5510fec0f7819ed35e85eaa667cd6c6baa2e09b 100644 (file)
@@ -5,58 +5,67 @@ import resolve from '@rollup/plugin-node-resolve'
 import commonjs from '@rollup/plugin-commonjs'
 import { terser } from 'rollup-plugin-terser'
 
-/** @type {import('rollup').RollupOptions} */
-const config = {
-  external: ['vue'],
-  output: {
-    file: path.resolve(__dirname, './dist/small.js'),
-    format: 'es',
-  },
-  input: path.resolve(__dirname, './small.js'),
-  plugins: [
-    replace({
-      preventAssignment: true,
-      values: {
-        __DEV__: 'false',
-        'process.env.NODE_ENV': JSON.stringify('production'),
-        // this is only used during tests
-        __TEST__: 'false',
-        // If the build is expected to run directly in the browser (global / esm builds)
-        __BROWSER__: 'true',
-        // is targeting bundlers?
-        __BUNDLER__: 'false',
-        __GLOBAL__: 'false',
-        // is targeting Node (SSR)?
-        __NODE_JS__: 'false',
-        __VUE_PROD_DEVTOOLS__: 'false',
-      },
-    }),
-    ts({
-      check: false,
-      tsconfig: path.resolve(__dirname, '../tsconfig.json'),
-      cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
-      tsconfigOverride: {
-        compilerOptions: {
-          sourceMap: false,
-          declaration: false,
-          declarationMap: false,
-        },
-        exclude: ['__tests__', 'test-dts'],
-      },
-    }),
-    resolve(),
-    commonjs(),
-    terser({
-      format: {
-        comments: false,
-      },
-      module: true,
-      compress: {
-        ecma: 2015,
-        pure_getters: true,
-      },
-    }),
-  ],
-}
+/** @type {import('rollup').RollupOptions[]} */
+const config = ['option-store', 'setup-store'].map(createConfig)
 
 export default config
+
+/**
+ *
+ * @param {string} file
+ * @returns {import('rollup').RollupOptions}
+ */
+function createConfig(file) {
+  return {
+    external: ['vue'],
+    output: {
+      file: path.resolve(__dirname, `./dist/${file}.js`),
+      format: 'es',
+    },
+    input: path.resolve(__dirname, `./${file}.js`),
+    plugins: [
+      replace({
+        preventAssignment: true,
+        values: {
+          __DEV__: 'false',
+          'process.env.NODE_ENV': JSON.stringify('production'),
+          // this is only used during tests
+          __TEST__: 'false',
+          // If the build is expected to run directly in the browser (global / esm builds)
+          __BROWSER__: 'true',
+          // is targeting bundlers?
+          __BUNDLER__: 'false',
+          __GLOBAL__: 'false',
+          // is targeting Node (SSR)?
+          __NODE_JS__: 'false',
+          __VUE_PROD_DEVTOOLS__: 'false',
+        },
+      }),
+      ts({
+        check: false,
+        tsconfig: path.resolve(__dirname, '../tsconfig.json'),
+        cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
+        tsconfigOverride: {
+          compilerOptions: {
+            sourceMap: false,
+            declaration: false,
+            declarationMap: false,
+          },
+          exclude: ['__tests__', 'test-dts'],
+        },
+      }),
+      resolve(),
+      commonjs(),
+      terser({
+        format: {
+          comments: false,
+        },
+        module: true,
+        compress: {
+          ecma: 2015,
+          pure_getters: true,
+        },
+      }),
+    ],
+  }
+}
diff --git a/size-checks/setup-store.js b/size-checks/setup-store.js
new file mode 100644 (file)
index 0000000..8870abc
--- /dev/null
@@ -0,0 +1,5 @@
+import { createPinia, defineSetupStore } from '../dist/pinia.esm-bundler'
+
+createPinia()
+// @ts-ignore
+export default defineSetupStore()
index f8e1fc795171b6367fe6de3f91636efe3f3c4cb8..7e74a2690c3dee2d5260167ab2852c1546d7b0d5 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -2780,7 +2780,7 @@ globals@^11.1.0:
   resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
   integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
 
-globby@^11.0.3:
+globby@^11.0.3, globby@^11.0.4:
   version "11.0.4"
   resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
   integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==