diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 84efd31e..964d7474 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,10 @@ jobs: with: name: build-artifacts retention-days: 1 - path: dist*/ + path: lib*/ - test-package: - name: Test package on node ${{ matrix.node }} / ${{ matrix.os }} / rollup v${{ matrix.rollup }} + test-package-rollup: + name: "rollup v${{ matrix.rollup }} / node ${{ matrix.node }} / ${{ matrix.os }}" needs: - build runs-on: ubuntu-latest @@ -99,16 +99,69 @@ jobs: npm install npm install rollup@${{ matrix.rollup }} --force npx rollup -v - working-directory: test/package + working-directory: test/package/rollup - name: Test package - run: npm run test:package + run: npm run test + working-directory: test/package/rollup + + test-package-vite: + name: "vite v${{ matrix.vite }} / node ${{ matrix.node }} / ${{ matrix.os }}" + needs: + - build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: ["22", "20", "18"] + os: [ubuntu-latest, windows-latest] + vite: ["5", "6", "7"] + exclude: + - os: windows-latest + node: 20 + - os: windows-latest + node: 18 + - vite: 7 + node: 18 + steps: + - name: Checkout repo + uses: actions/checkout@v5.0.0 + + - name: Setup node & npm + uses: relative-ci/.github/actions/setup-node-npm@v1.1.1 + with: + version: ${{ matrix.node }} + cache: never + install: false + + - name: Install vitest + run: npm install vitest + + - name: Download build files + uses: actions/download-artifact@v5.0.0 + with: + name: build-artifacts + + - name: Setup local npm registry + run: ./scripts/setup-registry.sh + + - name: Install test package dependencies + run: | + npm install + npm install vite@${{ matrix.vite }} --force + npx vite -v + working-directory: test/package/vite + + - name: Test package + run: npm run test + working-directory: test/package/vite tests: needs: - lint - test-unit - - test-package + - test-package-rollup + - test-package-vite runs-on: ubuntu-latest steps: - run: exit 0 diff --git a/.gitignore b/.gitignore index 29f34121..6a6f248a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.log .DS_Store node_modules -dist +lib .env diff --git a/package-lock.json b/package-lock.json index 172ea8d6..ed3c9d60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,20 @@ { "name": "rollup-plugin-webpack-stats", - "version": "2.1.4", + "version": "2.1.5-beta.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rollup-plugin-webpack-stats", - "version": "2.1.4", + "version": "2.1.5-beta.5", "license": "MIT", "dependencies": { - "rollup-plugin-stats": "1.5.0" + "rollup-plugin-stats": "1.5.1-beta.3" }, "devDependencies": { "@release-it/conventional-changelog": "10.0.1", + "@rollup/plugin-commonjs": "28.0.6", + "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-typescript": "12.1.4", "@tsconfig/node18": "18.2.4", "@types/node": "24.3.0", @@ -22,6 +24,7 @@ "release-it": "19.0.4", "rimraf": "6.0.1", "rollup": "4.46.4", + "rollup-plugin-node-externals": "8.1.0", "tslib": "2.8.1", "typescript": "5.9.2", "vitest": "3.2.4" @@ -1599,6 +1602,56 @@ "license": "MIT", "peer": true }, + "node_modules/@rollup/plugin-commonjs": { + "version": "28.0.6", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.6.tgz", + "integrity": "sha512-XSQB1K7FUU5QP+3lOQmVCE3I0FcbbNvmNT4VJSj93iUjayaARrTQeoRdiYQoftAJBLrR9t2agwAd3ekaTgHNlw==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.2.0", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.1.tgz", + "integrity": "sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-typescript": { "version": "12.1.4", "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.4.tgz", @@ -1982,6 +2035,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.7.0", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz", @@ -2479,6 +2538,12 @@ "dev": true, "license": "MIT" }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, "node_modules/compare-func": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-2.0.0.tgz", @@ -2795,6 +2860,15 @@ "node": ">=6" } }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/default-browser": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.2.1.tgz", @@ -3573,6 +3647,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "node_modules/is-obj": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", @@ -3583,6 +3663,15 @@ "node": ">=8" } }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-ssh": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.1.tgz", @@ -4699,10 +4788,32 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-node-externals": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-externals/-/rollup-plugin-node-externals-8.1.0.tgz", + "integrity": "sha512-0D3S0E0Dl1V3Q6Cywnc7wt88VAfOB9AC5QHwVdgvP1vByRHW2wnEXoK0x3VYZzJ/EmGsR5Uix5HUmMJNG+hz2Q==", + "dev": true, + "funding": [ + { + "type": "patreon", + "url": "https://patreon.com/Septh" + }, + { + "type": "paypal", + "url": "https://paypal.me/septh07" + } + ], + "engines": { + "node": ">= 21 || ^20.6.0 || ^18.19.0" + }, + "peerDependencies": { + "rollup": "^4.0.0" + } + }, "node_modules/rollup-plugin-stats": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-stats/-/rollup-plugin-stats-1.5.0.tgz", - "integrity": "sha512-TsWaV7ulwPA9JhqGJemrDJkvXNeNQb60lB13gIcT2kVDXlBM/PQD3GqVyhCJpvn43Y4YT5+VmWDRsbIAbuilBA==", + "version": "1.5.1-beta.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-stats/-/rollup-plugin-stats-1.5.1-beta.3.tgz", + "integrity": "sha512-lRX0oUgrsLCUZDwyuLAYz11qpbtb5WQgyKVToGwniaN2onNrlamqL5N+fIrIK6mmJUngXcX8xz+0qlG78c4UbQ==", "license": "MIT", "engines": { "node": ">=18" diff --git a/package.json b/package.json index eb2cb9ff..cde2ff01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rollup-plugin-webpack-stats", - "version": "2.1.4", + "version": "2.1.5-beta.5", "private": false, "license": "MIT", "keywords": [ @@ -11,19 +11,19 @@ "stats", "bundle-stats" ], - "main": "dist/index.cjs", - "module": "dist/index.mjs", - "typings": "dist/index.d.ts", + "main": "lib/cjs/index.js", + "module": "lib/esm/index.js", + "typings": "lib/types/index.d.ts", "exports": { ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/index.cjs" + "types": "./lib/types/index.d.ts", + "import": "./lib/esm/index.js", + "require": "./lib/cjs/index.js" }, "./transform": { - "types": "./dist/transform.d.ts", - "import": "./dist/transform.mjs", - "require": "./dist/transform.cjs" + "types": "./lib/types/transform.d.ts", + "import": "./lib/esm/transform.js", + "require": "./lib/cjs/transform.js" } }, "author": { @@ -40,17 +40,20 @@ }, "homepage": "https://github.com/relative-ci/rollup-plugin-webpack-stats/blob/master/#readme", "files": [ - "dist" + "lib" ], "engines": { "node": ">=18" }, "scripts": { - "prebuild": "rimraf ./dist", - "build": "tsc && rollup -c rollup.config.mjs", + "build": "npm run clean && rollup -c && npm run build-package-type", + "build-package-type": "echo '{\"type\":\"module\"}' > lib/esm/package.json", + "clean": "rimraf ./lib", "lint": "exit 0", "test:unit": "vitest test/unit", - "test:package": "cd test/package && vitest", + "test:package": "npm run test:package:rollup && npm run test:package:vite", + "test:package:rollup": "cd test/package/rollup && vitest", + "test:package:vite": "cd test/package/vite && vitest", "bump": "./scripts/bump.sh", "release": "./scripts/release.sh" }, @@ -67,6 +70,8 @@ }, "devDependencies": { "@release-it/conventional-changelog": "10.0.1", + "@rollup/plugin-commonjs": "28.0.6", + "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-typescript": "12.1.4", "@tsconfig/node18": "18.2.4", "@types/node": "24.3.0", @@ -76,17 +81,18 @@ "release-it": "19.0.4", "rimraf": "6.0.1", "rollup": "4.46.4", + "rollup-plugin-node-externals": "8.1.0", "tslib": "2.8.1", "typescript": "5.9.2", "vitest": "3.2.4" }, "dependencies": { - "rollup-plugin-stats": "1.5.0" + "rollup-plugin-stats": "1.5.1-beta.3" }, "peerDependencies": { - "vite": "^5.0.0 || ^6.0.0 || ^7.0.0", + "rolldown": "^1.0.0-beta.0", "rollup": "^3.0.0 || ^4.0.0", - "rolldown": "^1.0.0-beta.0" + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "peerDependenciesMeta": { "vite": { diff --git a/rollup.config.mjs b/rollup.config.mjs index 91d07488..42bc6db5 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,36 +1,65 @@ +import path from 'node:path'; import { defineConfig } from 'rollup'; -import typescript from '@rollup/plugin-typescript'; +import commonjsPlugin from '@rollup/plugin-commonjs'; +import nodeResolvePlugin from '@rollup/plugin-node-resolve'; +import typescriptPlugin from '@rollup/plugin-typescript'; + +const CONTEXT = path.join(import.meta.dirname, './src'); const INPUT = { 'index': './src/index.ts', 'transform': './src/transform.ts', }; -const OUTPUT_DIR = 'dist'; +const OUTPUT_DIR = 'lib'; export default defineConfig([ { + context: CONTEXT, input: INPUT, output: { dir: OUTPUT_DIR, - format: 'esm', - entryFileNames: '[name].mjs', - chunkFileNames: 'chunks/[name].mjs', + format: 'cjs', + entryFileNames: 'cjs/[name].js', sourcemap: true, + preserveModules: true, + preserveModulesRoot: CONTEXT, + interop: 'auto', }, - plugins: [typescript({ tsconfig: './tsconfig.json' })], - external: ['crypto', 'path'], + external: /node_modules/, + plugins: [ + nodeResolvePlugin({ + extensions: ['.js', '.cjs', '.json'], + }), + commonjsPlugin({ + defaultIsModuleExports: 'auto', + }), + typescriptPlugin({ + tsconfig: './tsconfig.lib-cjs.json', + }), + ], }, { + context: CONTEXT, input: INPUT, output: { dir: OUTPUT_DIR, - format: 'commonjs', - entryFileNames: '[name].cjs', - chunkFileNames: 'chunks/[name].cjs', + format: 'esm', + entryFileNames: 'esm/[name].js', sourcemap: true, + preserveModules: true, + preserveModulesRoot: CONTEXT, + interop: 'auto', }, - plugins: [typescript({ tsconfig: './tsconfig.json' })], - external: ['crypto', 'path'], + external: /node_modules/, + plugins: [ + nodeResolvePlugin({ + extensions: ['.js', '.mjs', '.cjs', '.json'], + }), + commonjsPlugin(), + typescriptPlugin({ + tsconfig: './tsconfig.lib-esm.json', + }), + ], }, ]); diff --git a/test/package/package.json b/test/package/package.json deleted file mode 100644 index 0905ec01..00000000 --- a/test/package/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "rollup-plugin-webpack-stats-test", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "build": "rollup -c", - "test": "vitest" - }, - "keywords": [], - "license": "ISC", - "devDependencies": { - "rollup": "^4.9.1", - "rollup-plugin-webpack-stats": "*" - } -} diff --git a/test/package/rollup/.gitignore b/test/package/rollup/.gitignore new file mode 100644 index 00000000..d2694976 --- /dev/null +++ b/test/package/rollup/.gitignore @@ -0,0 +1,2 @@ +package-lock.json +dist* diff --git a/test/package/rollup/case-config.js b/test/package/rollup/case-config.js new file mode 100644 index 00000000..1dbfe1c0 --- /dev/null +++ b/test/package/rollup/case-config.js @@ -0,0 +1,11 @@ +/* eslint-disable @typescript-eslint/no-require-imports */ +const { defineConfig } = require('rollup'); +const webpackStatsPlugin = require('rollup-plugin-webpack-stats'); + +module.exports = defineConfig({ + input: 'src/index.js', + output: { + dir: 'dist', + }, + plugins: [webpackStatsPlugin()], +}); diff --git a/test/package/rollup/case-config.mjs b/test/package/rollup/case-config.mjs new file mode 100644 index 00000000..17ff8443 --- /dev/null +++ b/test/package/rollup/case-config.mjs @@ -0,0 +1,10 @@ +import { defineConfig } from 'rollup'; +import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; + +export default defineConfig({ + input: 'src/index.js', + output: { + dir: 'dist', + }, + plugins: [webpackStatsPlugin()], +}); diff --git a/test/package/rollup/case-config.ts b/test/package/rollup/case-config.ts new file mode 100644 index 00000000..1bcd5353 --- /dev/null +++ b/test/package/rollup/case-config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'rollup'; +import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; + +export default defineConfig({ + input: 'src/index.js', + output: { + dir: 'dist', + }, + plugins: [webpackStatsPlugin({})], +}); diff --git a/test/package/rollup.config.mjs b/test/package/rollup/case-options.mjs similarity index 100% rename from test/package/rollup.config.mjs rename to test/package/rollup/case-options.mjs diff --git a/test/package/rollup/configs.test.ts b/test/package/rollup/configs.test.ts new file mode 100644 index 00000000..f113d500 --- /dev/null +++ b/test/package/rollup/configs.test.ts @@ -0,0 +1,22 @@ +import { promisify } from 'node:util'; +import { exec as execCallback} from 'node:child_process'; +import { describe, expect, test } from 'vitest'; + +const exec = promisify(execCallback); + +const testCases = [ + { type: 'commonjs', run: 'npm run build-commonjs' }, + { type: 'esm', run: 'npm run build-esm' }, + { type: 'ts', run: 'npm run build-ts' }, +]; + +describe('package - rollup configs', () => { + testCases.forEach((testCase) => { + test(`should build successfully with rollup ${testCase.type} config`, async () => { + const { stderr } = await exec(`cross-env NO_COLOR=true ${testCase.run}`); + + expect(stderr).toMatch('Stats saved to dist'); + expect(stderr).toMatch('created dist in'); + }); + }); +}); diff --git a/test/package/package.test.js b/test/package/rollup/options.test.ts similarity index 93% rename from test/package/package.test.js rename to test/package/rollup/options.test.ts index 5ec5e604..7ea2cc33 100644 --- a/test/package/package.test.js +++ b/test/package/rollup/options.test.ts @@ -4,9 +4,9 @@ import { beforeEach, describe, test, expect } from 'vitest'; import { rollup } from 'rollup'; import { vol } from 'memfs'; -import rollupConfig from './rollup.config'; +import rollupConfig from './case-options.mjs'; -describe('package test', () => { +describe('rollup options', () => { beforeEach(() => { vol.reset(); }); diff --git a/test/package/rollup/package.json b/test/package/rollup/package.json new file mode 100644 index 00000000..d143ab58 --- /dev/null +++ b/test/package/rollup/package.json @@ -0,0 +1,21 @@ +{ + "name": "rollup-plugin-webpack-stats-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "build-commonjs": "rollup -c case-config.js", + "build-esm": "rollup -c case-config.mjs", + "build-ts": "rollup --config case-config.ts --configPlugin typescript", + "test": "vitest" + }, + "keywords": [], + "license": "ISC", + "devDependencies": { + "@rollup/plugin-typescript": "^12.1.4", + "cross-env": "^7.0.0", + "rollup": "^4.9.1", + "rollup-plugin-webpack-stats": "file://../../../", + "typescript": "^5.9.2" + } +} diff --git a/test/package/src/index.js b/test/package/rollup/src/index.js similarity index 100% rename from test/package/src/index.js rename to test/package/rollup/src/index.js diff --git a/test/package/vite/.gitignore b/test/package/vite/.gitignore new file mode 100644 index 00000000..d2694976 --- /dev/null +++ b/test/package/vite/.gitignore @@ -0,0 +1,2 @@ +package-lock.json +dist* diff --git a/test/package/vite/case-config.js b/test/package/vite/case-config.js new file mode 100644 index 00000000..bc7b01c4 --- /dev/null +++ b/test/package/vite/case-config.js @@ -0,0 +1,16 @@ +/* eslint-disable @typescript-eslint/no-require-imports */ +const { defineConfig } = require('vite'); +const webpackStatsPlugin = require('rollup-plugin-webpack-stats'); + +module.exports = defineConfig({ + build: { + rollupOptions: { + output: { + assetFileNames: 'assets/[name][extname]', + chunkFileNames: 'assets/[name].js', + entryFileNames: 'assets/[name].js', + }, + }, + }, + plugins: [webpackStatsPlugin()], +}); diff --git a/test/package/vite/case-config.mjs b/test/package/vite/case-config.mjs new file mode 100644 index 00000000..2074bfa7 --- /dev/null +++ b/test/package/vite/case-config.mjs @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite'; +import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; + +export default defineConfig({ + build: { + rollupOptions: { + output: { + assetFileNames: 'assets/[name][extname]', + chunkFileNames: 'assets/[name].js', + entryFileNames: 'assets/[name].js', + }, + }, + }, + plugins: [webpackStatsPlugin()], +}); diff --git a/test/package/vite/case-config.ts b/test/package/vite/case-config.ts new file mode 100644 index 00000000..2074bfa7 --- /dev/null +++ b/test/package/vite/case-config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vite'; +import webpackStatsPlugin from 'rollup-plugin-webpack-stats'; + +export default defineConfig({ + build: { + rollupOptions: { + output: { + assetFileNames: 'assets/[name][extname]', + chunkFileNames: 'assets/[name].js', + entryFileNames: 'assets/[name].js', + }, + }, + }, + plugins: [webpackStatsPlugin()], +}); diff --git a/test/package/vite/case-options.mjs b/test/package/vite/case-options.mjs new file mode 100644 index 00000000..50fade1e --- /dev/null +++ b/test/package/vite/case-options.mjs @@ -0,0 +1,38 @@ +import { basename } from 'path'; +import { defineConfig } from 'vite'; +import webpackStats from 'rollup-plugin-webpack-stats'; + +const baseConfig = { + build: { + outDir: 'dist', + rollupOptions: { + output: { + assetFileNames: 'assets/[name][extname]', + chunkFileNames: 'assets/[name].js', + entryFileNames: 'assets/[name].js', + }, + }, + }, +}; + +export default defineConfig([ + { + ...baseConfig, + plugins: [webpackStats()], + }, + { + ...baseConfig, + build: { + ...baseConfig.build, + outDir: 'dist2', + }, + plugins: [ + // A contrived demo to show that plugin options can access vite outputOptions + webpackStats((outputOptions) => { + return { + fileName: `stats-${basename(outputOptions.dir)}.json`, + }; + }), + ], + }, +]); diff --git a/test/package/vite/configs.test.ts b/test/package/vite/configs.test.ts new file mode 100644 index 00000000..b4afc97b --- /dev/null +++ b/test/package/vite/configs.test.ts @@ -0,0 +1,22 @@ +import { promisify } from 'node:util'; +import { exec as execCallback} from 'node:child_process'; +import { describe, expect, test } from 'vitest'; + +const exec = promisify(execCallback); + +const testCases = [ + { type: 'commonjs', run: 'npm run build-commonjs' }, + { type: 'esm', run: 'npm run build-esm' }, + { type: 'ts', run: 'npm run build-ts' }, +]; + +describe('package - vite configs', () => { + testCases.forEach((testCase) => { + test(`should build successfully with rollup ${testCase.type} config`, async () => { + const { stdout } = await exec(`cross-env NO_COLOR=true ${testCase.run}`); + + expect(stdout).toMatch('Stats saved to'); + expect(stdout).toMatch('built in'); + }); + }); +}); diff --git a/test/package/vite/index.html b/test/package/vite/index.html new file mode 100644 index 00000000..63aef619 --- /dev/null +++ b/test/package/vite/index.html @@ -0,0 +1,10 @@ + + +
+ +