Skip to content

Commit

Permalink
Merge pull request #1061 from y-lohse/jz/publish-as-mjs
Browse files Browse the repository at this point in the history
Better packaging
  • Loading branch information
smwhr authored May 22, 2024
2 parents ed6f19a + 763f703 commit 20161b7
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- name: Install dependencies
run: npm install
- name: Install codecov
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/npm-manual-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- run: npm install
- run: npm run lint
- run: npm run build
Expand All @@ -23,11 +23,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20
- run: npm install
- run: npm run lint
- run: npm run build
Expand All @@ -25,11 +25,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm install
Expand Down
41 changes: 41 additions & 0 deletions ink.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Story, InkList } from './engine/Story'
import { Compiler } from './compiler/Compiler'
import { CompilerOptions } from './compiler/CompilerOptions'
import { PosixFileHandler } from './compiler/FileHandler/PosixFileHandler'
import { JsonFileHandler } from './compiler/FileHandler/JsonFileHandler'

declare interface Inkjs {
/**
* A Story is the core class that represents a complete Ink narrative, and
* manages runtime evaluation and state.
*/
Story: typeof Story

/**
* The underlying type for a list item in Ink.
*/
InkList: typeof InkList

/**
* Compiles Ink stories from source.
*/
Compiler: typeof Compiler

/**
* Metadata options for a compiler pass.
*/
CompilerOptions: typeof CompilerOptions

/**
* Resolves and loads Ink sources from a POSIX filesystem.
*/
PosixFileHandler: typeof PosixFileHandler

/**
* Resolves and loads Ink sources from a JSON hierarchy.
*/
JsonFileHandler: typeof JsonFileHandler
}

declare let inkjs: Inkjs
export default inkjs
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
{
"name": "inkjs",
"version": "2.2.3",
"version": "2.2.4",
"description": "A javascript port of inkle's ink scripting language (http://www.inklestudios.com/ink/)",
"type": "commonjs",
"main": "dist/ink-full.js",
"types": "ink.d.ts",
"files": ["src/engine","src/compiler","ink.d.ts", "ink.d.mts","script/inkjs-compiler.ts", "dist"],
"exports": {
".":{
"types": "./ink.d.mts",
"import": "./dist/ink.mjs",
"default": "./dist/ink.js"
},
"./full":{
"types": "./ink.d.mts",
"import": "./dist/ink-full.mjs",
"default": "./dist/ink-full.js"
}
},
"scripts": {
"test": "npm run test:typescript && npm run test:javascript",
"test:typescript": "jest",
Expand Down
22 changes: 21 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,27 @@ export default [
input: engineOnlyInputFile,
output: {
name: moduleName,
file: 'dist/ink-es6.js',
file: 'dist/ink.mjs',
format: 'es',
sourcemap: true
},
plugins: [
nodeResolve(),
typescript(tsconfig),
babel({
exclude: 'node_modules/**',
extensions: ['.js', '.ts'],
babelHelpers: 'bundled'
}),
terser(),
sourcemaps()
]
},
{
input: fullfeatureInputFile,
output: {
name: moduleName,
file: 'dist/ink-full.mjs',
format: 'es',
sourcemap: true
},
Expand Down

0 comments on commit 20161b7

Please sign in to comment.