Make more progress on package configuration, fill out C docs.

This commit is contained in:
Joshua Bemenderfer
2023-02-21 22:35:53 -05:00
parent fb90f825ed
commit 3b7077e761
19 changed files with 872 additions and 275 deletions

View File

@@ -1,6 +1,4 @@
MIT License
Copyright (c) 2022 Joshua Michael Bemenderfer
Copyright (c) 2022-present Joshua Michael Bemenderfer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.

View File

@@ -1,37 +1,41 @@
{
"name": "@terrace-lang/js",
"version": "0.0.1",
"description": "Terrace is a simple structured data syntax for configuration, content authoring, and DSLs.",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/terrace-lang/terrace.git",
"directory": "packages/js"
},
"bugs": "https://github.com/terrace-lang/terrace/issues",
"homepage": "https://terrace-lang.org",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./parser": {
"import": "./dist/parser.js",
"require": "./dist/parser.cjs"
},
"./document": {
"import": "./dist/document.js",
"require": "./dist/document.cjs"
},
"./readers/node-readline": {
"import": "./dist/readers/node-readline.js",
"require": "./dist/readers/node-readline.cjs"
},
"./readers/js-string": {
"import": "./dist/readers/js-string.js",
"require": "./dist/readers/js-string.cjs"
"./*": {
"types": "./dist/types/*.d.ts",
"import": "./dist/esm/*.js",
"require": "./dist/cjs/*.js"
}
},
"scripts": {
"test": "node ./test/index.js",
"dev": "vite build --watch",
"build": "vite build"
"dev": "run-p dev:*",
"dev:esm": "tsc --watch --project ./tsconfig.esm.json",
"dev:cjs": "tsc --watch --project ./tsconfig.cjs.json",
"dev:types": "tsc --watch --project ./tsconfig.types.json",
"build": "run-p build:*",
"build:esm": "tsc --project ./tsconfig.esm.json",
"build:cjs": "tsc --project ./tsconfig.cjs.json",
"build:types": "tsc --project ./tsconfig.types.json"
},
"devDependencies": {
"vite": "^3.2.3",
"vitest": "^0.24.5"
"@types/node": "^18.14.0",
"npm-run-all": "^4.1.5",
"typescript": "^4.9.5"
},
"engines": {
"node": ">=17.0.0",
"npm": ">=7.0.0"
}
}

View File

@@ -1,5 +1,5 @@
import type { Reader } from './readers/reader'
import { createLineData, parseLine } from './parser'
import type { Reader } from './readers/reader.js'
import { createLineData, parseLine } from './parser.js'
// Container for a handful of convenience functions for parsing documents
// Obtained from useDocument() below

View File

@@ -1,2 +1,2 @@
export * from './parser'
export * from './document'
export * from './parser.js'
export * from './document.js'

View File

@@ -1,4 +1,4 @@
import type { Reader } from './reader'
import type { Reader } from './reader.js'
/**
* Get a simple `Reader` function that always returns the next line

View File

@@ -1,6 +1,6 @@
import fs from 'node:fs'
import readline from 'node:readline/promises'
import type { Reader } from './reader'
import fs from 'fs'
import readline from 'readline/promises'
import type { Reader } from './reader.js'
/**

View File

@@ -1,18 +1,11 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 18",
"include": ["index.d.ts", "src/**/*"],
"compilerOptions": {
"lib": ["ES2022"],
"module": "ES2022",
"target": "ES2022",
"moduleResolution": "node",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true
},
"include": ["src/**/*"]
}
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"target": "ES2020",
"outDir": "./dist/cjs/",
}
}

View File

@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "ES2020",
"target": "ES2020",
"outDir": "./dist/esm/",
}
}

View File

@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true,
"declarationDir": "./dist/types",
}
}

View File

@@ -1,23 +0,0 @@
// vite.config.js
import { defineConfig } from 'vite'
export default defineConfig({
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
entry: {
'index': 'src/index.ts',
'document': 'src/document.ts',
'parser': 'src/parser.ts',
'readers/js-string': 'src/readers/js-string.ts',
'readers/node-readline': 'src/readers/node-readline.ts',
}
},
rollupOptions: {
external: [
`node:fs`,
`node:readline/promises`
]
}
}
})