-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9dd5bad
commit eece4ed
Showing
13 changed files
with
246 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Basic set up for three package managers | ||
|
||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
env: | ||
YARN_ENABLE_GLOBAL_CACHE: false | ||
|
||
jobs: | ||
build-and-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- 22 | ||
platform: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-latest | ||
|
||
name: "${{matrix.platform}} w/ Node.js ${{matrix.node}}.x" | ||
runs-on: ${{matrix.platform}} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: "Use Node.js ${{matrix.node}}.x" | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{matrix.node}}.x | ||
|
||
- run: npm install | ||
- run: npm run build | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Publish releases | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
release-please: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
release_created: ${{ steps.release.outputs.release_created }} | ||
release_tag: ${{ steps.release.outputs.tag_name }} | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: node | ||
package-name: amaro | ||
bump-minor-pre-major: true # TODO: remove this when releasing v1.0.0. | ||
|
||
npm-publish: | ||
needs: release-please | ||
if: ${{ needs.release-please.outputs.release_created }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/* | ||
|
||
- name: Publish to the npm registry | ||
run: | | ||
npm install | ||
npm publish | ||
env: | ||
NPM_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}} | ||
|
||
- run: npm pack --out amaro.tgz | ||
- name: Add Amaro package archive to GitHub release | ||
run: gh release upload ${{ needs.release-please.outputs.release_tag }} amaro.tgz | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
.vscode | ||
node_modules | ||
dist | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Code of Conduct | ||
|
||
Amaro is committed to upholding the Node.js Code of Conduct. | ||
|
||
The Node.js Code of Conduct document can be found at | ||
<https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# amaro | ||
Blessed Node.js TypeScript loader | ||
# Amaro | ||
|
||
Amaro is a wrapper around `@swc/wasm-typescript`, a WebAssembly port of the SWC TypeScript parser. | ||
It's currently used as an internal in Node.js for [Type Stripping](https://github.com/nodejs/loaders/issues/208), but can also be upgraded separately by users. | ||
|
||
> Amaro means "bitter" in Italian. It's a reference to [Mount Amaro](https://en.wikipedia.org/wiki/Monte_Amaro_(Abruzzo)) on whose slopes this package was conceived. | ||
## How to Install | ||
|
||
To install Amaro, run: | ||
|
||
```shell | ||
npm install -g amaro | ||
``` | ||
|
||
## License (MIT) | ||
|
||
See [`LICENSE.md`](./LICENSE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
}, | ||
"ignore": ["dist/**"] | ||
}, | ||
"formatter": { | ||
"enabled": true, | ||
"ignore": ["dist/**"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "amaro", | ||
"version": "0.0.1", | ||
"description": "Blessed Node.js TypeScript loader", | ||
"license": "MIT", | ||
"type": "commonjs", | ||
"main": "dist/index.js", | ||
"homepage": "https://github.com/marco-ippolito/amaro#readme", | ||
"bugs": { | ||
"url": "https://github.com/marco-ippolito/amaro/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/marco-ippolito/amaro.git" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf dist", | ||
"lint": "biome lint --write", | ||
"format": "biome format --write", | ||
"prepack": "npm run build", | ||
"postpack": "npm run clean", | ||
"build": "rspack build", | ||
"typecheck": "tsc --noEmit", | ||
"test": "node --test" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.8.3", | ||
"@rspack/cli": "^0.7.5", | ||
"@rspack/core": "^0.7.5", | ||
"@types/node": "^20.14.11", | ||
"rimraf": "^6.0.1", | ||
"typescript": "^5.5.3" | ||
}, | ||
"dependencies": { | ||
"@swc/wasm-typescript": "^1.6.13" | ||
}, | ||
"engines": { | ||
"node": "^22.4.0" | ||
}, | ||
"exports": { | ||
"./package.json": "./package.json" | ||
}, | ||
"files": [ | ||
"dist", | ||
"LICENSE.md" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
target: "node", | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts$/, | ||
exclude: [/node_modules/], | ||
loader: "builtin:swc-loader", | ||
options: { | ||
jsc: { | ||
parser: { | ||
syntax: "typescript", | ||
}, | ||
}, | ||
}, | ||
type: "javascript/auto", | ||
}, | ||
], | ||
}, | ||
output: { | ||
filename: "index.js", | ||
library: { | ||
type: "commonjs2", | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const { transformSync } = require("@swc/wasm-typescript"); | ||
|
||
function stripTypes(source: string): string { | ||
const result = transformSync(source, { | ||
mode: "strip-only", | ||
}); | ||
return result; | ||
} | ||
|
||
module.exports = { | ||
stripTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const { test } = require("node:test"); | ||
const assert = require("node:assert"); | ||
const { stripTypes } = require("../dist/index.js"); | ||
|
||
test("should perform type stripping", () => { | ||
assert.strictEqual(typeof stripTypes, "function"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": ".", | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"lib": ["ES2023"], | ||
"module": "commonjs", | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"verbatimModuleSyntax": true, | ||
"allowImportingTsExtensions": true, | ||
"strict": true, | ||
"target": "ES2022" | ||
} | ||
} |