Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ jobs:
- name: Build
run: pnpm build
working-directory: packages/arc-vue

- name: Test
run: pnpm test
working-directory: packages/arc-vue
7 changes: 5 additions & 2 deletions packages/arc-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
".": {
"types": "./dist/index.d.ts",
"import": "./dist/arc-vue.js"
}
},
"./style.css": "./dist/arc-vue.css"
},
"types": "./dist/index.d.ts",
"sideEffects": false,
"sideEffects": [
"**/*.css"
],
"scripts": {
"build": "vite build",
"typecheck": "vue-tsc --noEmit",
Expand Down
50 changes: 50 additions & 0 deletions packages/arc-vue/src/consumerPack.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { execSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';

const __dirname = dirname(fileURLToPath(import.meta.url));
const pkgRoot = join(__dirname, '..');
const corePkg = join(pkgRoot, '../../crates/koyori-arc-core/pkg');

describe('consumer pack', () => {
it('packs dist CSS and resolves @koyori-app/arc-vue/style.css', () => {
const pkg = JSON.parse(readFileSync(join(pkgRoot, 'package.json'), 'utf8')) as {
exports: Record<string, string | { import?: string }>;
sideEffects: string[];
};

const styleExport = pkg.exports['./style.css'];
expect(styleExport).toBe('./dist/arc-vue.css');
expect(pkg.sideEffects).toEqual(['**/*.css']);

const builtCss = join(pkgRoot, 'dist', 'arc-vue.css');
expect(readFileSync(builtCss, 'utf8').length).toBeGreaterThan(0);

const tmp = mkdtempSync(join(tmpdir(), 'arc-vue-pack-'));
try {
const packOutput = execSync(`pnpm pack --pack-destination "${tmp}"`, {
cwd: pkgRoot,
encoding: 'utf8',
});
const tarball = packOutput.trim().split('\n').at(-1)!;
expect(tarball).toMatch(/\.tgz$/);

const installDir = join(tmp, 'install');
execSync(`mkdir -p "${installDir}"`, { encoding: 'utf8' });
execSync(
`npm install "${tarball}" "file:${corePkg}" --legacy-peer-deps --no-save`,
{ cwd: installDir, encoding: 'utf8', stdio: 'pipe' },
);

const require = createRequire(join(installDir, 'package.json'));
const resolved = require.resolve('@koyori-app/arc-vue/style.css');
expect(readFileSync(resolved, 'utf8')).toContain('.koyori-gantt-scroll');
} finally {
rmSync(tmp, { recursive: true, force: true });
}
});
});