Skip to content

Commit

Permalink
Make the repo an NPM package (#9)
Browse files Browse the repository at this point in the history
* Change main file to index.ts

* Change main to pre-defined index

* Add index file at root

This is to allow 'slang' imports. The rootDir has been changed to '.'
since the index file exists here. In addition, the main file in
package.json has been changed to the root index file.

* Change index to src/index

This is because we will be exporting everything to the /dist directory
anyways.

* Add types export for tsconfig

Allows exporting types for the built files. Also changed rootDir

* Fix shadowing name error

When building, the Error type returned could also refer to Error defined
in node. So, I explicitly defined the return type.

* Change properties for publishing

- Change main and typings
- Add files to be included in publishing
- Add pre-publish script

* Use types property

Typings will be deprecated

* Change name and author

* Add organization name
  • Loading branch information
remo5000 authored and ning-y committed Jul 10, 2018
1 parent 1c032bf commit 832922c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
{
"name": "slang",
"name": "@source-academy/js-slang",
"version": "0.1.0",
"description": "Javascript-based interpreter for slang, written in Typescript",
"author": {
"name" : "Source Academy",
"url" : "https://github.com/source-academy/"
},
"dependencies": {
"acorn": "^5.7.1",
"astring": "^1.2.0",
"commander": "^2.14.1",
"common-tags": "^1.4.0",
"invariant": "^2.2.2"
},
"main": "slang.js",
"bin": {
"slang": "slang.js"
},
"main": "dist/index",
"types": "dist/index",
"files": [
"dist"
],
"scripts": {
"prepublishOnly": "tsc",

This comment has been minimized.

Copy link
@ning-y

ning-y Oct 4, 2018

Member

@remo5000 Actually, is this necessary, if there's already a build script that does the same thing? Does the npm publishing toolchain require an exact key in scripts with the name prepublishOnly?

"build": "tsc",
"test": "jest"
},
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { evaluate } from './interpreter'
import { InterruptedError } from './interpreter-errors'
import { parse } from './parser'
import { AsyncScheduler, PreemptiveScheduler } from './schedulers'
import { Context, Result, Scheduler, SourceError } from './types'
import { Context, Error, Finished, Result, Scheduler, SourceError } from './types'

export interface IOptions {
scheduler: 'preemptive' | 'async'
Expand Down Expand Up @@ -47,7 +47,7 @@ export function runInContext(
}
}

export function resume(result: Result) {
export function resume(result: Result): Finished | Error | Promise<Result> {
if (result.status === 'finished' || result.status === 'error') {
return result
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class ArrowClosure {
}
}

interface Error {
export interface Error {
status: 'error'
}

Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"outDir": "./dist",
"module": "CommonJS",
"declaration": true,
"target": "es2016",
"lib": [
"es2017.object",
Expand All @@ -24,7 +25,8 @@
"noUnusedLocals": true
},
"exclude": [
"node_modules"
"node_modules",
"dist"
],
"types": [
"typePatches"
Expand Down

0 comments on commit 832922c

Please sign in to comment.