Skip to content

Commit

Permalink
chore(build): enable full type check and fix type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed May 14, 2024
1 parent f1428d5 commit 594350c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-assets-retry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dist"
],
"scripts": {
"build": "modern build && node scripts/postCompile.js",
"build": "modern build && node scripts/postCompile.mjs",
"dev": "modern build --watch"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
const path = require('node:path');
const { readFile, writeFile, mkdir } = require('node:fs/promises');
const { transformAsync } = require('@babel/core');
const { performance } = require('node:perf_hooks');
import { existsSync } from 'node:fs';
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import { transformAsync } from '@babel/core';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
* transform ../src/runtime/${filename}.ts
Expand Down Expand Up @@ -48,11 +53,17 @@ async function compileRuntimeFile(filename) {

async function compile() {
const startTime = performance.now();
await mkdir(path.join(__dirname, '../dist/runtime'));

const runtimeDir = path.join(__dirname, '../dist/runtime');
if (!existsSync(runtimeDir)) {
await mkdir(runtimeDir);
}

await Promise.all([
compileRuntimeFile('initialChunkRetry'),
compileRuntimeFile('asyncChunkRetry'),
]);

console.log(
`Compiled assets retry runtime code. Time cost: ${(
performance.now() - startTime
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-image-compress/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface CodecBaseOptions {
jpeg: JpegCompressOptions;
png: PngQuantOptions;
pngLossless: PNGLosslessOptions;
ico: Record<string, never>;
ico: Record<string, unknown>;
svg: SvgoConfig;
}

Expand Down
10 changes: 7 additions & 3 deletions scripts/modern.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export const buildConfigWithMjs: PartialBaseBuildConfig[] = [
define,
autoExtension: true,
externals,
dts: {
respectExternal: false,
},
dts: false,
},
{
format: 'esm',
Expand All @@ -64,6 +62,12 @@ export const buildConfigWithMjs: PartialBaseBuildConfig[] = [
externals,
banner: requireShim,
},
{
buildType: 'bundleless',
dts: {
only: true,
},
},
];

export const configWithMjs = defineConfig({
Expand Down

0 comments on commit 594350c

Please sign in to comment.