Skip to content

Commit

Permalink
feat: bundle-recast
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 6, 2023
1 parent fecae8e commit 16b55ba
Show file tree
Hide file tree
Showing 41 changed files with 661 additions and 653 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 lint
- run: pnpm build
- run: pnpm vitest --coverage
- run: pnpm test --coverage
- run: pnpm 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'
})
}
}
});
2 changes: 1 addition & 1 deletion helpers.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./dist/helpers.d.ts";
export * from "./dist/helpers.js";
39 changes: 35 additions & 4 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.15",
"@babel/types": "^7.22.15",
"recast": "^0.23.4"
"source-map-js": "^1.0.2"
},
"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",
"eslint": "^8.48.0",
"execa": "^8.0.1",
"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",
"tiged": "^2.12.5",
"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

0 comments on commit 16b55ba

Please sign in to comment.