Skip to content

Commit

Permalink
fix(angular-store): Use ng-packagr as build tool (#62)
Browse files Browse the repository at this point in the history
* Use ng-packagr

* Simplify

* Fix tsconfig

* Fix knip
  • Loading branch information
lachlancollins authored Jun 20, 2024
1 parent caa60c7 commit 8fa8ec3
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 140 deletions.
3 changes: 0 additions & 3 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"workspaces": {
"packages/angular-store": {
"ignoreDependencies": ["@angular/compiler-cli"]
},
"packages/vue-store": {
"ignoreDependencies": ["vue2", "vue2.7"]
}
Expand Down
9 changes: 9 additions & 0 deletions packages/angular-store/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "src/index.ts"
},
"allowedNonPeerDependencies": ["@tanstack/store"],
"dest": "dist",
"deleteDestPath": false
}
41 changes: 20 additions & 21 deletions packages/angular-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:lib": "vitest",
"test:lib:dev": "pnpm run test:lib --watch",
"test:build": "publint --strict",
"build": "vite build"
"build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./dist/package.json"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand All @@ -28,38 +28,37 @@
"url": "https://github.com/sponsors/tannerlinsley"
},
"type": "module",
"types": "dist/esm/index.d.ts",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.js",
"types": "dist/index.d.ts",
"module": "dist/fesm2022/tanstack-angular-store.mjs",
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/index.d.cts",
"default": "./dist/cjs/index.cjs"
}
"./package.json": {
"default": "./package.json"
},
"./package.json": "./package.json"
".": {
"types": "./dist/index.d.ts",
"esm2022": "./dist/esm2022/tanstack-angular-store.mjs",
"esm": "./dist/esm2022/tanstack-angular-store.mjs",
"default": "./dist/fesm2022/tanstack-angular-store.mjs"
}
},
"sideEffects": false,
"files": [
"dist",
"src"
],
"dependencies": {
"@tanstack/store": "workspace:*"
"@tanstack/store": "workspace:*",
"tslib": "^2.3.0"
},
"devDependencies": {
"@analogjs/vite-plugin-angular": "^1.5.0",
"@angular/common": "^17.1.2",
"@angular/compiler": "^17.1.2",
"@angular/compiler-cli": "^17.1.2",
"@angular/core": "^17.1.2",
"@angular/platform-browser": "^17.1.2",
"@angular/platform-browser-dynamic": "^17.1.2",
"@angular/common": "^17.3.0",
"@angular/compiler": "^17.3.0",
"@angular/compiler-cli": "^17.3.0",
"@angular/core": "^17.3.0",
"@angular/platform-browser": "^17.3.0",
"@angular/platform-browser-dynamic": "^17.3.0",
"ng-packagr": "^17.3.0",
"zone.js": "^0.14.3"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component, effect } from '@angular/core'
import { TestBed } from '@angular/core/testing'
import { By } from '@angular/platform-browser'
import { Store } from '@tanstack/store'
import { injectStore } from '../index'
import { injectStore } from '../src/index'

describe('injectStore', () => {
test(`allows us to select state using a selector`, () => {
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions packages/angular-store/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "./node_modules/ng-packagr/lib/ts/conf/tsconfig.ngc.json",
"compilerOptions": {
"moduleResolution": "bundler",
"allowJs": true,
"moduleDetection": "force",
"module": "ESNext"
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true
},
"include": ["src/**/*.ts", ".eslintrc.cjs"]
}
2 changes: 1 addition & 1 deletion packages/angular-store/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"@tanstack/store": ["../store/src"]
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", ".eslintrc.cjs", "vite.config.ts"]
"include": ["src", "tests", ".eslintrc.cjs", "vite.config.ts"]
}
12 changes: 0 additions & 12 deletions packages/angular-store/tsconfig.legacy.json

This file was deleted.

20 changes: 5 additions & 15 deletions packages/angular-store/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import { defineConfig, mergeConfig } from 'vitest/config'
import { tanstackBuildConfig } from '@tanstack/config/build'
import { defineConfig } from 'vitest/config'

const config = defineConfig({
export default defineConfig({
test: {
name: 'angular-store',
dir: './src',
dir: './tests',
watch: false,
environment: 'jsdom',
setupFiles: ['src/tests/test-setup.ts'],
setupFiles: ['tests/test-setup.ts'],
globals: true,
coverage: { enabled: true, provider: 'istanbul', include: ['src/**/*'] },
typecheck: { enabled: true },
globals: true,
},
})

export default mergeConfig(
config,
tanstackBuildConfig({
entry: './src/index.ts',
srcDir: './src',
exclude: ['./src/tests'],
}),
)
Loading

0 comments on commit 8fa8ec3

Please sign in to comment.