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: 2 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ In the early stages of the project, we [had some difficulties](https://dev.to/an
Corresponding tasks are defined in the `package.json.scripts`:
```json
{
"prebuild": "rm -rf build",
"prebuild": "node -e \"require('node:fs').rmSync('build', { recursive: true, force: true })\"",
"build": "npm run build:js && npm run build:dts && npm run build:tests",
"build:js": "node scripts/build-js.mjs --format=cjs --hybrid --entry=src/*.ts:!src/error.ts:!src/repl.ts:!src/md.ts:!src/log.ts:!src/globals-jsr.ts:!src/goods.ts && npm run build:vendor",
"build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all --external='./internals.ts'",
Expand Down Expand Up @@ -188,7 +188,7 @@ Static analyzers are responsible for code quality.
```json
{
"fmt:check": "prettier --check .",
"test:circular": "madge --circular src/*"
"test:circular": "madge --circular --extensions ts src"
}
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"scripts": {
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
"prebuild": "rm -rf build",
"prebuild": "node -e \"require('node:fs').rmSync('build', { recursive: true, force: true })\"",
"build": "npm run build:versions && npm run build:js && npm run build:dts && npm run build:tests",
"build:js": "node scripts/build-js.mjs --format=cjs --hybrid --entry='src/{cli,core,deps,globals,index,internals,util,vendor*}.ts' && npm run build:vendor",
"build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all --external='./internals.ts'",
Expand All @@ -93,7 +93,7 @@
"test:dcr": "node ./test/it/build-dcr.test.js",
"test:unit": "node --experimental-transform-types ./test/all.test.js",
"test:coverage": "c8 -c .nycrc --check-coverage npm run test:unit",
"test:circular": "madge --circular src/*",
"test:circular": "madge --circular --extensions ts src",
"test:types": "tsd",
"test:license": "node ./test/extra.test.js",
"test:audit": "node scripts/npm-audit.js",
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-js.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import path from 'node:path'
import fs from 'node:fs'
import { fileURLToPath } from 'node:url'
import esbuild from 'esbuild'
import { injectCode, injectFile } from 'esbuild-plugin-utils'
import { nodeExternalsPlugin } from 'esbuild-node-externals'
Expand All @@ -27,7 +28,7 @@ import esbuildResolvePlugin from 'esbuild-plugin-resolve'
import minimist from 'minimist'
import glob from 'fast-glob'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const __dirname = path.dirname(fileURLToPath(import.meta.url))

const argv = minimist(process.argv.slice(2), {
default: {
Expand Down
4 changes: 3 additions & 1 deletion scripts/build-jsr.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

import fs from 'node:fs'
import path from 'node:path'
const __dirname = path.dirname(new URL(import.meta.url).pathname)
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.resolve(__dirname, '..')
const pkgJson = JSON.parse(
fs.readFileSync(path.resolve(root, 'package.json'), 'utf-8')
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-pkgjson-lite.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { depseekSync } from 'depseek'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.resolve(__dirname, '..')
const source = 'package.json'
const dest = 'package-lite.json'
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-pkgjson-main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.resolve(__dirname, '..')
const source = 'package.json'
const dest = 'package-main.json'
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-size-limit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import fs from 'node:fs'
import path from 'node:path'
import { spawnSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'

const root = path.resolve(new URL(import.meta.url).pathname, '../..')
const root = path.resolve(fileURLToPath(import.meta.url), '../..')
const configPath = path.join(root, '.size-limit.json')
const original = fs.readFileSync(configPath, 'utf8')
const config = JSON.parse(original)
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import * as core from '../build/core.js'
import * as cli from '../build/cli.js'
import * as index from '../build/index.js'
Expand All @@ -26,7 +27,7 @@ const modules = [
['cli', cli],
['index', index],
]
const root = path.resolve(new URL(import.meta.url).pathname, '../..')
const root = path.resolve(fileURLToPath(import.meta.url), '../..')
const filePath = path.resolve(root, `test/export.test.js`)

const copyright = fs.readFileSync(
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

import fs from 'fs-extra'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import minimist from 'minimist'

const root = path.resolve(new URL(import.meta.url).pathname, '../..')
const root = path.resolve(fileURLToPath(import.meta.url), '../..')
const copyright = fs.readFileSync(
path.resolve(root, 'test/fixtures/copyright.txt'),
'utf8'
Expand Down
3 changes: 2 additions & 1 deletion test/extra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@

import assert from 'node:assert'
import { test, describe } from 'node:test'
import { fileURLToPath } from 'node:url'
import { globby, fs, path } from '../build/index.js'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const __dirname = path.dirname(fileURLToPath(import.meta.url))

describe('extra', () => {
test('every file should have a license', async () => {
Expand Down
3 changes: 2 additions & 1 deletion test/it/build-jsr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

import { tempdir, $, path, fs } from '../../build/index.js'
import { describe, before, after, it } from 'node:test'
import { fileURLToPath } from 'node:url'

const __dirname = path.dirname(new URL(import.meta.url).pathname)
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.resolve(__dirname, '../../')

describe('jsr artifact', () => {
Expand Down