Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: bundle recast #81

Merged
merged 13 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
dist
vendor
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:
node-version: 18
cache: "pnpm"
- run: pnpm install
- run: pnpm lint
- run: pnpm build
- run: pnpm vitest --coverage
- run: pnpm lint
- run: pnpm run test --coverage
- run: pnpm run test:build
- uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ types
*.env*
.idea
.history
vendor
22 changes: 22 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { resolve } from "node:path";
import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
Expand All @@ -6,5 +7,26 @@ export default defineBuildConfig({
declaration: true,
rollup: {
emitCJS: true,
inlineDependencies: true,
dts: {
respectExternal: true,
}
},
alias: {
'source-map': 'source-map-js',
// eslint-disable-next-line unicorn/prefer-module
assert: resolve(__dirname, 'stubs/assert/index.js'),
// eslint-disable-next-line unicorn/prefer-module
recast: resolve(__dirname, 'vendor/recast/main.ts'),
// eslint-disable-next-line unicorn/prefer-module
'ast-types': resolve(__dirname, 'vendor/ast-types/src/main.ts'),
},
hooks: {
'rollup:dts:options': (ctx, options) => {
// @ts-expect-error filter out commonjs plugin in dts build
options.plugins = options.plugins.filter((plugin) => {
return plugin && plugin.name !== 'commonjs'
})
}
}
});
37 changes: 34 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,46 @@
],
"scripts": {
"build": "unbuild",
"prepare": "esno ./scripts/vendor.ts",
pi0 marked this conversation as resolved.
Show resolved Hide resolved
"dev": "vitest dev",
"dev:ui": "vitest dev --ui",
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w",
"prepack": "pnpm run build",
"typecheck": "tsc --noEmit",
"release": "pnpm run test run && changelogen --release && npm publish && git push --follow-tags",
"test": "vitest"
"test": "vitest",
"test:build": "TEST_BUILD=true vitest",
"test:full": "pnpm run test && pnpm run build && pnpm run test:build"
},
"dependencies": {
"@babel/parser": "^7.22.15",
"@babel/types": "^7.22.15",
"recast": "^0.23.4"
"source-map-js": "^1.0.2"
pi0 marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/node": "^20.5.9",
"@vitest/coverage-v8": "^0.34.3",
"@vitest/ui": "^0.34.3",
"ast-types": "^0.16.1",
"changelogen": "^0.5.5",
"eslint": "^8.48.0",
"eslint-config-unjs": "^0.2.1",
"esno": "^0.17.0",
"giget": "^1.1.2",
"lint-staged": "^14.0.1",
"magicast": "workspace:*",
"prettier": "^3.0.3",
"recast": "^0.23.4",
"simple-git-hooks": "^2.9.0",
"source-map": "npm:source-map-js@latest",
"typescript": "^5.2.2",
"unbuild": "^2.0.0",
"vitest": "^0.34.3"
},
"resolutions": {
"source-map": "npm:source-map-js@latest"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
},
Expand All @@ -64,5 +76,24 @@
"prettier -w"
]
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"array-includes": "npm:@nolyfill/array-includes@latest",
"array.prototype.flat": "npm:@nolyfill/array.prototype.flat@latest",
"array.prototype.flatmap": "npm:@nolyfill/array.prototype.flatmap@latest",
"available-typed-arrays": "npm:@nolyfill/available-typed-arrays@latest",
"define-properties": "npm:@nolyfill/define-properties@latest",
"function-bind": "npm:@nolyfill/function-bind@latest",
"gopd": "npm:@nolyfill/gopd@latest",
"has": "npm:@nolyfill/has@latest",
"has-symbols": "npm:@nolyfill/has-symbols@latest",
"has-tostringtag": "npm:@nolyfill/has-tostringtag@latest",
"is-arguments": "npm:@nolyfill/is-arguments@latest",
"is-generator-function": "npm:@nolyfill/is-generator-function@latest",
"object-is": "npm:@nolyfill/object-is@latest",
"object.values": "npm:@nolyfill/object.values@latest",
"which-typed-array": "npm:@nolyfill/which-typed-array@latest"
}
}
}
Loading
Loading