Skip to content

Commit

Permalink
build: bundle recast (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Sep 15, 2023
1 parent 0d65b23 commit a439ffa
Show file tree
Hide file tree
Showing 21 changed files with 480 additions and 500 deletions.
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ jobs:
- run: pnpm install
- run: pnpm build
- run: pnpm lint
- run: pnpm vitest --coverage
- 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
20 changes: 20 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,24 @@ 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
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'
})
}
}
});
41 changes: 36 additions & 5 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",
"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.16",
"@babel/types": "^7.22.17",
"recast": "^0.23.4"
"@babel/types": "^7.22.19",
"source-map-js": "^1.0.2"
},
"devDependencies": {
"@types/node": "^20.6.0",
"@vitest/coverage-v8": "^0.34.4",
"@vitest/ui": "^0.34.4",
"ast-types": "^0.16.1",
"changelogen": "^0.5.5",
"eslint": "^8.49.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.4"
},
"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

0 comments on commit a439ffa

Please sign in to comment.