Skip to content

Commit b796e65

Browse files
committed
Update core-build-tasks to partially bundle in order to handle ESM only
dependencies from commonjs invocations. Add release publishing task to core-build-tasks and integrate it into minecraft math so that the pre-built bundle is included in releases. Integrate this release publish into the release pipeline.
1 parent 6923e5b commit b796e65

17 files changed

+709
-697
lines changed

.github/workflows/pull-request.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
pull_request:
55
branches:
66
- main
7-
push:
8-
branches:
9-
- rlanda/testPipeline
107

118
jobs:
129
build:
@@ -19,6 +16,4 @@ jobs:
1916
with:
2017
node-version: 20
2118
- run: npm ci
22-
- run: npm run test
23-
env:
24-
TEST_VAR: 'CheckVarFromJust'
19+
- run: npm run test

.github/workflows/release-changes.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ jobs:
1818
uses: actions/setup-node@v4
1919
with:
2020
node-version: 20
21-
- name: GH Release
22-
uses: softprops/[email protected]
2321
- run: npm ci
2422
- run: npm run test # Fully build the repo so we have artifacts available to create releases, include tests so we don't ship in a broken state
2523

@@ -36,4 +34,5 @@ jobs:
3634
- name: Publish
3735
run: npm run release -- --token "$NPM_TOKEN" --yes --new
3836
env:
39-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
37+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
REPO_PAT: ${{ secrets.REPO_PAT }}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ lib-cjs
44
dist
55
temp
66
node_modules
7-
*.tgz
7+
*.tgz
8+
*.zip

.vscode/launch.json

-16
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"type": "major",
3-
"comment": "Export both ESM and CJS, but exclusively use CJS for just task configuration",
4-
"packageName": "@minecraft/core-build-tasks",
5-
"email": "[email protected]",
6-
"dependentChangeType": "patch"
2+
"type": "major",
3+
"comment": "Export both ESM and CJS, but exclusively use CJS for just task configuration. Pre-bundle most dependencies to deal with ESM exclusive dependencies",
4+
"packageName": "@minecraft/core-build-tasks",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"type": "major",
3-
"comment": "Switch to ESM exclusively",
4-
"packageName": "@minecraft/math",
5-
"email": "[email protected]",
6-
"dependentChangeType": "patch"
2+
"type": "major",
3+
"comment": "Switch to ESM exclusively. Publish release with artifacts.",
4+
"packageName": "@minecraft/math",
5+
"email": "[email protected]",
6+
"dependentChangeType": "major"
77
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"type": "major",
3-
"comment": "Switch to CJS exclusively, and update to ESLint 9",
4-
"packageName": "eslint-plugin-minecraft-linting",
5-
"email": "[email protected]",
6-
"dependentChangeType": "patch"
2+
"type": "major",
3+
"comment": "Switch to CJS exclusively, and update to ESLint 9",
4+
"packageName": "eslint-plugin-minecraft-linting",
5+
"email": "[email protected]",
6+
"dependentChangeType": "major"
77
}

libraries/math/just.config.cts

+20-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import {
55
apiExtractorTask,
66
cleanTask,
77
coreLint,
8+
publishReleaseTask,
89
vitestTask,
910
} from '@minecraft/core-build-tasks';
11+
import { copyFileSync, createWriteStream, readFileSync } from 'node:fs';
12+
import { resolve } from 'node:path';
1013

1114
const isOnlyBuild = argv()._.findIndex(arg => arg === 'test') === -1;
1215

@@ -20,18 +23,30 @@ task('bundle', () => {
2023
execSync(
2124
'npx esbuild ./lib/index.js --bundle --outfile=dist/minecraft-math.js --format=esm --sourcemap --external:@minecraft/server'
2225
);
26+
// Copy over type definitions and rename
27+
const officialTypes = JSON.parse(readFileSync('./package.json', 'utf-8'))['types'];
28+
if (!officialTypes) {
29+
// Has the package.json been restructured?
30+
throw new Error('The package.json file does not contain a "types" field. Unable to copy types to bundle.');
31+
}
32+
const officialTypesPath = resolve(officialTypes);
33+
copyFileSync(officialTypesPath, './dist/minecraft-math.d.ts');
2334
});
2435
task('build', series('typescript', 'api-extractor-local', 'bundle'));
2536

26-
// Post-build test to confirm environment variable propagates through various build scripts
27-
task('postbuild', () => {
28-
console.log(`The environment variable TEST_VAR is set to: ${process.env.TEST_VAR}`);
29-
});
30-
3137
// Test
3238
task('api-extractor-validate', apiExtractorTask('./api-extractor.json', isOnlyBuild /* localBuild */));
3339
task('vitest', vitestTask());
3440
task('test', series('api-extractor-validate', 'vitest'));
3541

3642
// Clean
3743
task('clean', cleanTask(DEFAULT_CLEAN_DIRECTORIES));
44+
45+
// Post-publish
46+
task('postpublish', () => {
47+
return publishReleaseTask({
48+
repoOwner: 'Mojang',
49+
repoName: 'minecraft-scripting-libraries',
50+
message: 'See attached zip for pre-built minecraft-math bundle with type declarations.',
51+
});
52+
});

libraries/math/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
},
2222
"scripts": {
2323
"build": "just build",
24-
"postbuild": "just postbuild",
2524
"lint": "just lint",
2625
"test": "just test",
27-
"clean": "just clean"
26+
"clean": "just clean",
27+
"postpublish": "just postpublish"
2828
},
2929
"license": "MIT",
3030
"files": [

0 commit comments

Comments
 (0)