Skip to content

Commit

Permalink
fix(npm): fix builds and exports
Browse files Browse the repository at this point in the history
BREAKING CHANGE: may break imports and/or cause new build errors
  • Loading branch information
EdieLemoine committed Mar 13, 2024
1 parent 5f8a237 commit 3aa81f2
Show file tree
Hide file tree
Showing 47 changed files with 560 additions and 161 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vite.config.ts.timestamp-*
*.sln
*.suo
*.sw?
*.tgz
.AppleDouble
.DS_Store
.LSOverride
Expand Down
12 changes: 8 additions & 4 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
"license": "MIT",
"type": "module",
"scripts": {
"build": "vite build",
"build:dev": "vite build --mode development",
"clean": "rimraf dist",
"build": "run ws:vite:build \"$(pwd)\"",
"build:dev": "run ws:vite:build:dev \"$(pwd)\"",
"clean": "run ws:clean \"$(pwd)\"",
"serve": "vite",
"typecheck": "run ws:vue:typecheck \"$(pwd)\""
"test": "run ws:test \"$(pwd)\"",
"test:coverage": "run ws:test:coverage \"$(pwd)\"",
"test:run": "run ws:test:run \"$(pwd)\"",
"test:update": "run ws:test:update \"$(pwd)\"",
"typecheck": "run ws:vite:typecheck \"$(pwd)\""
},
"dependencies": {
"@myparcel/constants": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/Bonnetje.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<script lang="ts">
import {computed, defineComponent} from 'vue';
import {useForm} from '@myparcel/vue-form-builder/ts';
import {useForm} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'Bonnetje',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/ComponentWithoutElementProp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup lang="ts">
import {useVModel} from '@vueuse/core';
import {useElement} from '@myparcel/vue-form-builder/ts';
import {useElement} from '@myparcel/vue-form-builder';
// eslint-disable-next-line vue/no-unused-properties
const props = defineProps<{modelValue: string}>();
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/FormDiagnostics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<script generic="V extends FormValues" lang="ts" setup>
import {toRefs} from 'vue';
import {type MaybeUnwrapNestedRefs, type FormValues} from '@myparcel-vfb/core';
import {type FormInstance} from '@myparcel/vue-form-builder/ts';
import {type FormInstance} from '@myparcel/vue-form-builder';
import {useFormEventLog} from '../composables/useFormEventLog';
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/FormGroupWithoutElementProp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</template>

<script setup lang="ts">
import {useElement} from '@myparcel/vue-form-builder/ts';
import {useElement} from '@myparcel/vue-form-builder';
const element = useElement();
</script>
2 changes: 1 addition & 1 deletion apps/demo/src/components/Heading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script lang="ts">
import {type PropType, defineComponent} from 'vue';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'Heading',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/FormGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<script lang="ts">
import {defineComponent, type PropType, type UnwrapNestedRefs} from 'vue';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
import {translate} from '../../translate';
import ErrorBox from './ErrorBox.vue';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {type PlainElementInstance} from '@myparcel/vue-form-builder/ts';
import {type PlainElementInstance} from '@myparcel/vue-form-builder';
import LoadingOverlay from '../LoadingOverlay.vue';
import {translate} from '../../translate';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/THiddenInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {useVModel} from '@vueuse/core';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'TTextInput',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TNumberInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {useVModel} from '@vueuse/core';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'TNumberInput',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TResetButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {type PlainElementInstance} from '@myparcel/vue-form-builder/ts';
import {type PlainElementInstance} from '@myparcel/vue-form-builder';
import {translate} from '../../translate';
import TButton from './TButton.vue';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<script lang="ts">
import {computed, type ComputedRef, defineComponent, type PropType, watch} from 'vue';
import {useVModel} from '@vueuse/core';
import {type InteractiveElementInstance, type SelectOption} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance, type SelectOption} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'TSelect',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TSubmitButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {type PlainElementInstance} from '@myparcel/vue-form-builder/ts';
import {type PlainElementInstance} from '@myparcel/vue-form-builder';
import LoadingOverlay from '../LoadingOverlay.vue';
import {translate} from '../../translate';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TTextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import {defineComponent, type PropType} from 'vue';
import {useVModel} from '@vueuse/core';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'TTextInput',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TToggleSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
/* eslint-disable vue/no-unused-properties */
import {defineComponent, type PropType} from 'vue';
import {useVModel} from '@vueuse/core';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
export default defineComponent({
name: 'TToggleSwitch',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/components/template/TableFormGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<script lang="ts">
import {type PropType, defineComponent} from 'vue';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {type InteractiveElementInstance} from '@myparcel/vue-form-builder';
import {translate} from '../../translate';
export default defineComponent({
Expand Down
4 changes: 2 additions & 2 deletions apps/demo/src/composables/useAddressForm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable */
// @ts-nocheck
import {defineForm, Form, SelectOption} from '@myparcel/vue-form-builder/ts';
import {defineForm, SelectOption, FormInstance} from '@myparcel/vue-form-builder';

const postcodeHousenumberValidation = async (form: Form) => {
const postcodeHousenumberValidation = async (form: FormInstance) => {
form.model.postcodeHousenumberValidation.visible = false;

if (form.model.postcode && form.model.housenumber && form.model.country === 'NL') {
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/forms/noPropForm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ref} from 'vue';
import {defineField, defineForm} from '@myparcel/vue-form-builder/ts';
import {defineField, defineForm} from '@myparcel/vue-form-builder';
import FormGroupWithoutElementProp from '../components/FormGroupWithoutElementProp.vue';
import ComponentWithoutElementProp from '../components/ComponentWithoutElementProp.vue';

Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/forms/shipmentOptionsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-magic-numbers */
import {ref, toValue} from 'vue';
import {defineField, defineForm, type InteractiveElementInstance} from '@myparcel/vue-form-builder/ts';
import {defineField, defineForm, type InteractiveElementInstance} from '@myparcel/vue-form-builder';
import {isOfType} from '@myparcel/ts-utils';
import {type CarrierName, PACKAGE_TYPE_IDS_TO_NAMES, PackageTypeName} from '@myparcel/constants';
import {translate} from '../translate';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './assets/main.scss';
import {createApp} from 'vue';
import {VueQueryPlugin} from '@tanstack/vue-query';
import {MyParcelFormBuilderPlugin} from '@myparcel/vue-form-builder/ts';
import {MyParcelFormBuilderPlugin} from '@myparcel/vue-form-builder';
import router from './router';
import App from './App.vue';

Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/test/elementTypes.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type PlainElementConfiguration,
defineField,
defineForm,
} from '@myparcel/vue-form-builder/ts';
} from '@myparcel/vue-form-builder';

const interactiveFieldConfig = {
name: 'name',
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/validation/stringContainsValidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {type Validator} from '@myparcel/vue-form-builder/ts';
import {type Validator} from '@myparcel/vue-form-builder';
import {type OneOrMore, toArray} from '@myparcel/ts-utils';

export const stringContainsValidator = (search: OneOrMore<string>): Validator<string> => {
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/views/EditAddressView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>

<script lang="ts" setup>
import {MagicForm} from '@myparcel/vue-form-builder/ts';
import {MagicForm} from '@myparcel/vue-form-builder';
import {useAddressForm} from '../composables/useAddressForm';
const form = useAddressForm();
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/views/NoPropView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script lang="ts" setup>
import {MagicForm} from '@myparcel/vue-form-builder/ts';
import {MagicForm} from '@myparcel/vue-form-builder';
import {noPropForm} from '../forms/noPropForm';
import FormDiagnostics from '../components/FormDiagnostics.vue';
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/views/ShipmentOptionsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<script lang="ts" setup>
import {computed, ref, watch, toValue} from 'vue';
import {type FormInstance} from '@myparcel-vfb/core';
import {MagicForm} from '@myparcel/vue-form-builder/ts';
import {MagicForm} from '@myparcel/vue-form-builder';
import {shipmentOptionsForm} from '../forms/shipmentOptionsForm';
import FormDiagnostics from '../components/FormDiagnostics.vue';
Expand Down
9 changes: 5 additions & 4 deletions apps/demo/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';
import {createViteConfig} from '@myparcel-vfb/build-vite';

export default defineConfig({
plugins: [vue()],
export default createViteConfig({
build: {
lib: false,
},

esbuild: {
jsxFactory: 'h',
Expand Down
34 changes: 11 additions & 23 deletions apps/vue-form-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,28 @@
],
"license": "MIT",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.cjs",
"default": "./dist/index.cjs"
}
},
"./ts": {
"types": "./dist/index.d.ts",
"import": "./src/index.ts"
}
},
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"./dist",
"./src"
"./dist"
],
"scripts": {
"build": "vite build",
"build:dev": "vite build --mode development",
"build": "run ws:vite:build \"$(pwd)\"",
"build:dev": "run ws:vite:build:dev \"$(pwd)\"",
"clean": "run ws:clean \"$(pwd)\"",
"typecheck": "run ws:ts:typecheck \"$(pwd)\""
"test": "run ws:test \"$(pwd)\"",
"test:coverage": "run ws:test:coverage \"$(pwd)\"",
"test:run": "run ws:test:run \"$(pwd)\"",
"test:update": "run ws:test:update \"$(pwd)\"",
"typecheck": "run ws:vite:typecheck \"$(pwd)\""
},
"dependencies": {
"@myparcel-vfb/core": "workspace:^1.0.0-beta.39",
"@myparcel-vfb/hook-manager": "workspace:^1.0.0-beta.11",
"@myparcel-vfb/plugin": "workspace:^1.0.0-beta.39",
"@myparcel-vfb/utils": "workspace:^1.0.0-beta.6",
"@myparcel/ts-utils": "^1.6.0",
"@vueuse/core": "^10.1.2"
"@myparcel/ts-utils": ">= 1.6.0",
"@vueuse/core": ">= 10.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
Expand Down
31 changes: 2 additions & 29 deletions apps/vue-form-builder/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,8 @@
import {copyFileSync} from 'node:fs';
import dts from 'vite-plugin-dts';
import customTsConfig from 'vite-plugin-custom-tsconfig';
import {defineConfig} from 'vite';
import vue from '@vitejs/plugin-vue';

export default defineConfig((env) => {
const isProd = env.mode === 'production';
import {createViteConfig} from '@myparcel-vfb/build-vite';

export default createViteConfig(() => {
return {
plugins: [
vue(),
dts({
entryRoot: 'src',
afterBuild: () => {
// To pass publint (`npm x publint@latest`) and ensure the
// package is supported by all consumers, we must export types that are
// read as ESM. To do this, there must be duplicate types with the
// correct extension supplied in the package.json exports field.
copyFileSync('dist/index.d.ts', 'dist/index.d.cts');
},
}),
customTsConfig(),
],
build: {
minify: false,
sourcemap: !isProd,
lib: {
entry: 'src/index.ts',
fileName: 'index',
formats: ['es', 'cjs'],
},
rollupOptions: {
external: ['vue', '@myparcel/ts-utils', '@vueuse/core'],
output: {
Expand Down
7 changes: 7 additions & 0 deletions libs/build-vite/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {type ConfigEnv, type UserConfigExport} from 'vitest/dist/config';
import {type UserConfigFn} from 'vitest/config';
import {type PromiseOr, type RecursivePartial} from '@myparcel/ts-utils';

declare function createViteConfig(
config?: PromiseOr<RecursivePartial<UserConfigExport> | ((env: ConfigEnv) => RecursivePartial<UserConfigExport>)>,
): UserConfigFn;
Loading

0 comments on commit 3aa81f2

Please sign in to comment.