Skip to content

Commit debc2ae

Browse files
committed
Move to @import syntax
1 parent 0f16d6a commit debc2ae

23 files changed

+1187
-812
lines changed

bin.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env node
22

3+
/**
4+
* @import {DomStackOpts as DomStackOpts} from './lib/builder.js'
5+
* @import { ArgscloptsParseArgsOptionsConfig } from 'argsclopts'
6+
*/
7+
38
import { readFile } from 'node:fs/promises'
49
import { resolve, join, relative } from 'node:path'
510
import { parseArgs } from 'node:util'
@@ -19,11 +24,6 @@ import { DomStackAggregateError } from './lib/helpers/dom-stack-aggregate-error.
1924
import { generateTreeData } from './lib/helpers/generate-tree-data.js'
2025
import { askYesNo } from './lib/helpers/cli-prompt.js'
2126

22-
/**
23-
* @import {DomStackOpts as DomStackOpts} from './lib/builder.js'
24-
* @import { ArgscloptsParseArgsOptionsConfig } from 'argsclopts'
25-
*/
26-
2727
const __dirname = import.meta.dirname
2828

2929
async function getPkg () {

dependencygraph.svg

Lines changed: 1029 additions & 650 deletions
Loading

index.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
/**
2+
* @import { DomStackOpts as DomStackOpts, Results } from './lib/builder.js'
3+
* @import { FSWatcher, Stats } from 'node:fs'
4+
* @import { PostVarsFunction, LayoutFunction } from './lib/build-pages/page-data.js'
5+
* @import { PageFunction } from './lib/build-pages/page-builders/page-writer.js'
6+
* @import { TemplateFunction } from './lib/build-pages/page-builders/template-builder.js'
7+
* @import { TemplateAsyncIterator } from './lib/build-pages/page-builders/template-builder.js'
8+
* @import { TemplateOutputOverride } from './lib/build-pages/page-builders/template-builder.js'
9+
* @import { BuildOptions } from 'esbuild'
10+
*/
111
import { once } from 'events'
212
import assert from 'node:assert'
313
import chokidar from 'chokidar'
414
import { basename, relative, resolve } from 'node:path'
5-
// @ts-ignore
15+
// @ts-expect-error
616
import makeArray from 'make-array'
717
import ignore from 'ignore'
8-
// @ts-ignore
18+
// @ts-expect-error
919
import cpx from 'cpx2'
1020
import { inspect } from 'util'
1121
import browserSync from 'browser-sync'
@@ -16,41 +26,36 @@ import { builder } from './lib/builder.js'
1626
import { DomStackAggregateError } from './lib/helpers/dom-stack-aggregate-error.js'
1727

1828
/**
19-
* @import { DomStackOpts as DomStackOpts, Results } from './lib/builder.js'
20-
* @import { FSWatcher, Stats } from 'node:fs'
21-
*/
22-
23-
/**
24-
* @typedef {import('esbuild').BuildOptions} BuildOptions
29+
* @typedef {BuildOptions} BuildOptions
2530
*/
2631

2732
/**
2833
* @template {Record<string, any>} T
29-
* @typedef {import('./lib/build-pages/resolve-layout.js').LayoutFunction<T>} LayoutFunction
34+
* @typedef {LayoutFunction<T>} LayoutFunction
3035
*/
3136

3237
/**
3338
* @template {Record<string, any>} T
34-
* @typedef {import('./lib/build-pages/resolve-vars.js').PostVarsFunction<T>} PostVarsFunction
39+
* @typedef {PostVarsFunction<T>} PostVarsFunction
3540
*/
3641

3742
/**
3843
* @template {Record<string, any>} T
39-
* @typedef {import('./lib/build-pages/page-builders/page-writer.js').PageFunction<T>} PageFunction
44+
* @typedef {PageFunction<T>} PageFunction
4045
*/
4146

4247
/**
4348
* @template {Record<string, any>} T
44-
* @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateFunction<T>} TemplateFunction
49+
* @typedef {TemplateFunction<T>} TemplateFunction
4550
*/
4651

4752
/**
4853
* @template {Record<string, any>} T
49-
* @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateAsyncIterator<T>} TemplateAsyncIterator
54+
* @typedef {TemplateAsyncIterator<T>} TemplateAsyncIterator
5055
*/
5156

5257
/**
53-
* @typedef {import('./lib/build-pages/page-builders/template-builder.js').TemplateOutputOverride} TemplateOutputOverride
58+
* @typedef {TemplateOutputOverride} TemplateOutputOverride
5459
*/
5560

5661
const DEFAULT_IGNORES = /** @type {const} */ ([

lib/build-copy/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
// @ts-ignore
1+
/**
2+
* @import { BuildStepResult, BuildStep } from '../builder.js'
3+
*/
4+
5+
// @ts-expect-error
26
import cpx from 'cpx2'
37
import { join } from 'node:path'
48
const copy = cpx.copy
59

610
/**
11+
* @typedef {BuildStepResult<'static', CopyBuilderReport>} CopyBuildStepResult
12+
* @typedef {BuildStep<'static', CopyBuilderReport>} CopyBuildStep
713
* @typedef {Awaited<ReturnType<typeof copy>>} CopyBuilderReport
814
*/
915

10-
/**
11-
* @typedef {import('../builder.js').BuildStepResult<'static', CopyBuilderReport>} CopyBuildStepResult
12-
*/
13-
14-
/**
15-
* @typedef {import('../builder.js').BuildStep<'static', CopyBuilderReport>} CopyBuildStep
16-
*/
17-
1816
/**
1917
* @param {string[]} copy
2018
* @return {string[]}

lib/build-esbuild/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @import { BuildStep } from '../builder.js'
3+
*/
4+
15
import { writeFile } from 'fs/promises'
26
import { join, relative, basename } from 'path'
37
import esbuild from 'esbuild'
@@ -13,7 +17,7 @@ const DOM_STACK_DEFAULTS_PREFIX = 'dom-stack-defaults'
1317
* @typedef {esbuild.BuildOptions} EsbuildBuildOptions
1418
* @typedef {Awaited<ReturnType<esbuild.build>>} EsbuildBuildResults
1519
16-
* @typedef {import('../builder.js').BuildStep<
20+
* @typedef {BuildStep<
1721
* 'esbuild',
1822
* {
1923
* buildResults?: EsbuildBuildResults
@@ -23,7 +27,8 @@ const DOM_STACK_DEFAULTS_PREFIX = 'dom-stack-defaults'
2327
* >} EsBuildStep
2428
*/
2529

26-
/** @typedef {Awaited<ReturnType<EsBuildStep>>} EsBuildStepResults
30+
/**
31+
* @typedef {Awaited<ReturnType<EsBuildStep>>} EsBuildStepResults
2732
*/
2833

2934
/**

lib/build-pages/index.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
/**
2+
* @import { BuilderOptions } from './page-builders/page-writer.js'
3+
* @import { BuildStep } from '../builder.js'
4+
* @import { LayoutFunction } from './page-data.js'
5+
*/
6+
17
import { Worker } from 'worker_threads'
28
import { join } from 'path'
39
import pMap from 'p-map'
410
import { cpus } from 'os'
5-
6-
/**
7-
* @import { BuilderOptions } from './page-builders/page-writer.js'
8-
*/
911
import { keyBy } from '../helpers/key-by.js'
1012
import { resolveVars } from './resolve-vars.js'
11-
import { resolveLayout } from './resolve-layout.js'
1213
import { pageBuilders, templateBuilder } from './page-builders/index.js'
13-
import { PageData } from './page-data.js'
14+
import { PageData, resolveLayout } from './page-data.js'
1415
import { pageWriter } from './page-builders/page-writer.js'
1516

1617
const MAX_CONCURRENCY = Math.min(cpus().length, 24)
@@ -25,21 +26,16 @@ const __dirname = import.meta.dirname
2526
*/
2627

2728
/**
28-
* @typedef {import('../builder.js').BuildStep<
29+
* @typedef {BuildStep<
2930
* 'page',
3031
* PageBuilderReport
31-
* >} PageBuildStep
32+
* >} PageBuildStep
3233
*/
3334

3435
/**
3536
* @typedef {Awaited<ReturnType<PageBuildStep>>} PageBuildStepResult
3637
*/
3738

38-
/**
39-
* @template T
40-
* @typedef {import('./resolve-layout.js').LayoutFunction<T>} LayoutFunction
41-
*/
42-
4339
/**
4440
* @template T
4541
* @typedef ResolvedLayout

lib/build-pages/page-builders/html/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
/**
2+
* @import { PageBuilderType } from '../page-writer.js'
3+
*/
4+
15
import assert from 'node:assert'
26
import { readFile } from 'fs/promises'
37
import Handlebars from 'handlebars'
48

59
/**
610
* Build all of the bundles using esbuild.
711
* @template {Record<string, any>} T
8-
* @type {import('../page-writer.js').PageBuilderType<T>}
12+
* @type {PageBuilderType<T>}
913
*/
1014
export async function htmlBuilder ({ pageInfo }) {
1115
assert(pageInfo.type === 'html', 'html builder requires a "html" page type')

lib/build-pages/page-builders/js/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
/**
2+
* @import { PageBuilderType } from '../page-writer.js'
3+
*/
4+
15
import assert from 'node:assert'
26

37
/**
48
* Build all of the bundles using esbuild.
59
* @template {Record<string, any>} T
6-
* @type {import('../page-writer.js').PageBuilderType<T>}
10+
* @type {PageBuilderType<T>}
711
*/
812
export async function jsBuilder ({ pageInfo }) {
913
assert(pageInfo.type === 'js', 'js page builder requires "js" page type')

lib/build-pages/page-builders/md/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* @import markdownIt from 'markdown-it'
3+
* @import { PageBuilderType } from '../page-writer.js'
34
*/
45
import assert from 'node:assert'
56
import { readFile } from 'fs/promises'
@@ -14,7 +15,7 @@ let md = null
1415
/**
1516
* Build all of the bundles using esbuild.
1617
* @template {Record<string, any>} T
17-
* @type {import('../page-writer.js').PageBuilderType<T>}
18+
* @type {PageBuilderType<T>}
1819
*/
1920
export async function mdBuilder ({ pageInfo, options }) {
2021
assert(pageInfo.type === 'md', 'md builder requires an "md" page type')

lib/build-pages/page-builders/page-writer.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import { join } from 'path'
2-
import { writeFile, mkdir } from 'fs/promises'
3-
41
/**
5-
* @typedef {import('../../identify-pages.js').PageInfo} PageInfo
6-
* @typedef {import('../../builder.js').SiteData} SiteData
7-
* @typedef {import('../../identify-pages.js').PageFileAsset} PageFileAsset
2+
* @import { PageInfo } from '../../identify-pages.js'
3+
* @import { PageData } from '../page-data.js'
84
*/
95

6+
import { join } from 'path'
7+
import { writeFile, mkdir } from 'fs/promises'
8+
109
/**
1110
* @typedef {Object} BuilderOptions
1211
* @property {string | null | undefined} [markdownItSettingsPath] - Path to the markdown-it settings file
1312
*/
1413

1514
/**
1615
* @template {Record<string, any>} T
17-
* @typedef {import('../page-data.js').PageData<T>} PageData
16+
* @typedef {PageData<T>} PageData
1817
*/
1918

2019
/**

0 commit comments

Comments
 (0)