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

Emit compiled bundle #15

Closed
unlight opened this issue Mar 20, 2021 · 5 comments
Closed

Emit compiled bundle #15

unlight opened this issue Mar 20, 2021 · 5 comments
Labels

Comments

@unlight
Copy link
Owner

unlight commented Mar 20, 2021

People want have single big file with generated classes instead of multiple.
Similar issues: #6 #12

Facts:

  • ts-morph allows to emit compiled file with declarations
  • classes are not hoisted and must be properly sorted to avoid fall into TDZ
  • Unable to maintain it (make manual changes, etc.)

What need to do before:

  • Decouple generation, get rid of dependency of SourceFile in different types of handlers
  • Create helper function to resort classes
  • Emit dts with errors
unlight pushed a commit that referenced this issue Mar 29, 2021
## [10.3.0](v10.2.0...v10.3.0) (2021-03-29)

### Features

* Allow generate compiled files or merged to single file ([095f975](095f975)), closes [#15](#15)
@unlight
Copy link
Owner Author

unlight commented Mar 29, 2021

🎉 This issue has been resolved in version 10.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@unlight
Copy link
Owner Author

unlight commented Mar 29, 2021

Check new options emitSingle and emitCompiled
https://github.com/unlight/prisma-nestjs-graphql#emitsingle
https://github.com/unlight/prisma-nestjs-graphql#emitcompiled

@yassinebridi
Copy link

It works like a charm @unlight, the performance too is really good, thank you.

@yassinebridi
Copy link

@unlight I just tried the emitSingle opiton, i think there is a dead zone issue, where for example:
a UserCreateNestedManyWithoutCityInput is trying to access UserWhereUniqueInput, befor the latter is created.

@unlight
Copy link
Owner Author

unlight commented Mar 29, 2021

@yassinebridi emitDecoratorMetadata is creating such problem

class User {
    @Field(() => Post)
    post!: Post;
}
class Post {
    @Field(() => User)
    user!: User;
}
class User {
}
__decorate([
    Field(() => Post),
    __metadata("design:type", Post)
], User.prototype, "post", void 0);
class Post {
}
__decorate([
    Field(() => User),
    __metadata("design:type", User)
], Post.prototype, "user", void 0);

__metadata tries immediately access to class, (it's not lazy like Field).

I guess you cannot disable it, since NestJS depends on it.
So, it means emitSingle and emitCompiled should be enabled together. I'll update documentation.

I just figure out how it can be solved, using weird trick:

class User {
    @Field(() => Post)
    post!: InstanceType<typeof Post>;
}
class Post {
    @Field(() => User)
    user!: InstanceType<typeof User>;
}

It will generate __metadata("design:type", void 0)

compiledcode83 pushed a commit to compiledcode83/nestjs-graphql-prisma-api-test that referenced this issue Jun 5, 2022
## [10.3.0](unlight/prisma-nestjs-graphql@v10.2.0...v10.3.0) (2021-03-29)

### Features

* Allow generate compiled files or merged to single file ([095f975](unlight/prisma-nestjs-graphql@095f975)), closes [#15](unlight/prisma-nestjs-graphql#15)
Krystal2002 added a commit to Krystal2002/prisma that referenced this issue Aug 9, 2022
## [10.3.0](unlight/prisma-nestjs-graphql@v10.2.0...v10.3.0) (2021-03-29)

### Features

* Allow generate compiled files or merged to single file ([095f975](unlight/prisma-nestjs-graphql@095f975)), closes [#15](unlight/prisma-nestjs-graphql#15)
SuperStar444 added a commit to SuperStar444/graphql-nestjs-prisma that referenced this issue Sep 20, 2022
## [10.3.0](unlight/prisma-nestjs-graphql@v10.2.0...v10.3.0) (2021-03-29)

### Features

* Allow generate compiled files or merged to single file ([095f975](unlight/prisma-nestjs-graphql@095f975)), closes [#15](unlight/prisma-nestjs-graphql#15)
github-actions bot pushed a commit to resident-advisor/prisma-nestjs-graphql that referenced this issue Mar 20, 2024
## 1.0.0 (2024-03-20)

### ⚠ BREAKING CHANGES

* Bump version
* Update packages
* Require `@prisma/client` v4.12+
Must be used with optional dependency `prisma-graphql-type-decimal` v3.0.0+
* Update library to support to Prisma v4
* @type decorator will be added to all input classes
* **other:** defaults `input` and `output` in PropertyType to false
* Configuration `useInputType` changed underlying library for pattern matching
https://github.com/axtgr/outmatch, prefix renamed to `match:`
* Removed deprecated setting `types_*`
* Model is regenerating ignoring existing data, any manual changes will be discarded
* Enum is regerating now, any manual changes will be discarded
* **compatibility:** Possible breaking change aggregation keywords use underscore as prefix to prevent field clashes
* Adapted to Prisma 2.20
* Renamed token `{feature}` to `{model}` in `outputFilePattern` template pattern
* Removed `renameZooTypes` config option
* Config option `combineScalarFilters` is false by default
* Made all options which mutates/renames types are `false`
* Inverted config option `atomicNumberOperations` to `noAtomicNumberOperations`
Replace `atomicNumberOperations = false` by `noAtomicNumberOperations = true`
* Adapt generator to Prisma 2.16
* Typescript property type now same as graphql type
* Generated types tries to be compatible with Prisma types,
nullability (optional/required) changed for input types
* **prisma:** Adapt generator to Prisma v2.13
* Switched to replace mode generation of files, all extra field which are not exists in model will be
removed
* Generator options: dasherizedName renamed to name
* Adapted to prisma 2.12
* Adapted generator to Prisma 2.8

### Features

* @PropertyType() to replace types_ configuration ([4a7313d](4a7313d))
* `useInputType` config option allow to choose input type ([54eeb1c](54eeb1c))
* Ability to hide field in schema ([a222955](a222955)), closes [unlight#8](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/8)
* Adapted generator to Prisma 2.14 ([26a23c4](26a23c4))
* Adapted generator to Prisma 2.15 ([77b87a6](77b87a6))
* Add options to generate only selected blocks ([cabe9bd](cabe9bd))
* add the prisma client import option ([00c81d5](00c81d5))
* Allow add deprecation reason ([432e8f1](432e8f1)), closes [unlight#104](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/104)
* Allow generate compiled files or merged to single file ([095f975](095f975)), closes [unlight#15](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/15)
* Allow hide property using decorate in config ([b83beeb](b83beeb))
* Allow the use of the generate function without the `onGenerate` ([a566cca](a566cca)), closes [unlight#168](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/168) [unlight#169](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/169)
* Allow to configure path to `tsconfig.json` ([ead4411](ead4411))
* Alternative default import configuration ([4ae1b82](4ae1b82))
* Apply custom decorators on models ([34196b3](34196b3))
* Combine zoo of nested/nullable filters ([20f965b](20f965b))
* **compatibility:** New configuration option `unsafeCompatibleWhereUniqueInput` ([72a3dab](72a3dab)), closes [unlight#177](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/177)
* **configuration:** Allow purge output folder ([a360869](a360869)), closes [unlight#7](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/7)
* **configuration:** Allow to map prisma scalars to custom graphql scalars ([59300e1](59300e1)), closes [unlight#87](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/87)
* **configuration:** Option to disable ID graphql type ([8474da7](8474da7)), closes [unlight#44](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/44)
* Custom decorators ([b14f0fe](b14f0fe))
* **custom decorators:** Abstract and rename type ([eb68ca6](eb68ca6)), closes [unlight#40](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/40)
* **custom decorators:** Allow apply custom decorator on models ([52f090a](52f090a)), closes [unlight#63](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/63)
* **custom decorators:** Allow attach `@Directive()` ([d6faef0](d6faef0))
* **custom decorators:** New `decorate` generator setting ([c5e14b7](c5e14b7)), closes [unlight#48](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/48)
* **custom decorators:** New `decorate` generator setting ([db970f0](db970f0)), closes [unlight#48](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/48)
* Custom graphql field mapping ([10fb039](10fb039))
* Custom property mapping ([f8cc54d](f8cc54d))
* Duplicate comments in jsdoc ([002a055](002a055)), closes [unlight#39](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/39)
* Export all classes from one file ([92ca651](92ca651)), closes [unlight#5](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/5)
* Extend `reExport` option ([3d5475b](3d5475b))
* First release ([340a105](340a105))
* Generate aggregate input types ([66239bb](66239bb))
* Generate args types ([5015de7](5015de7))
* Generate commented class if re-export found ([dc3e268](dc3e268))
* Generate JSON scalar type ([82007d7](82007d7))
* Generate other output types ([55e5cd5](55e5cd5))
* **hide field:** Allow hide field in type matching by pattern ([6c05123](6c05123)), closes [unlight#37](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/37)
* **match:** Allows `match` expressions in `FieldType` and `PropertyType` ([unlight#60](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/60)) ([a9b0e46](a9b0e46))
* New option rename zoo types ([04cb5af](04cb5af))
* New token `{plural.type}` for outputFilePattern generator options ([51cc938](51cc938))
* Option to disable atomic number operations ([3319ff9](3319ff9))
* **require single uniq filter:** New `requireSingleFieldsInWhereUniqueInput` generator setting ([7ee73eb](7ee73eb)), closes [unlight#58](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/58)
* Skip write stage for files with no changes ([ecc2fb8](ecc2fb8))
* Support reexport with custom output pattern ([2786894](2786894))
* Use Prisma.Decimal typescript type ([0395e5f](0395e5f))
* Validate `outputFilePattern` ([3240a73](3240a73))

### Bug Fixes

* `tsConfigFilePath` is ignored ([d98e146](d98e146)), closes [unlight#88](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/88)
* Adapt new native types ([f1ba6bc](f1ba6bc))
* Adapted generator to Prisma 2.8 ([4ac4779](4ac4779))
* Adapted to prisma 2.12 ([7e0ab3f](7e0ab3f))
* Adapted to Prisma 2.20 ([c5f040d](c5f040d)), closes [unlight#17](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/17)
* Added more keywords for detection model name ([51c836e](51c836e))
* Added new feature split keywords ([e780043](e780043))
* AwaitEventEmitter is not a constructor ([6f97126](6f97126)), closes [unlight#200](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/200)
* BigInt property type in lower ([19ace4e](19ace4e))
* Combine scalar filters on nullable list ([8f306e8](8f306e8))
* Combine scalar filters with `fieldReference` ([1f1ef9c](1f1ef9c)), closes [unlight#148](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/148)
* Combine scalars option with nullable relation filter ([471c405](471c405))
* **combine scalars:** Bytes filter ([6b0a156](6b0a156))
* Compatibility Issues with Prisma 5 ([1e1bee3](1e1bee3)), closes [unlight#179](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/179)
* **compatibility:** Add typescript null type for optional fields in model ([df0b9de](df0b9de)), closes [unlight#57](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/57)
* **compatibility:** Make model types compatible from both sides Prisma and GraphQL ([c015f12](c015f12)), closes [unlight#41](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/41)
* **compatibility:** Rename aggregation keywords ([83491c8](83491c8))
* Compound primary key generated type ([64a9854](64a9854)), closes [unlight#182](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/182)
* Conflict with models ending with `Output` ([a08d4c4](a08d4c4)), closes [unlight#10](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/10)
* Corrected scalar property type for where type ([b9e5937](b9e5937))
* Create bin script ([a6c2573](a6c2573)), closes [unlight#92](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/92)
* Create decimal value object ([f368231](f368231)), closes [unlight#113](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/113)
* **custom decorators:** `FieldType` respect input/output in generator settings ([a075e00](a075e00)), closes [unlight#34](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/34)
* **custom decorators:** FieldType mapping for output types ([c036a10](c036a10)), closes [unlight#55](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/55)
* **custom decorators:** Missed imports when enabled `emitSingle` ([bf55996](bf55996)), closes [unlight#28](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/28)
* **custom decorators:** Prevent applying on aggregate inputs ([9b21970](9b21970))
* **custom decorators:** Reget decorator full name ([9e279bf](9e279bf)), closes [unlight#29](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/29)
* Custom field types array ([ead56a4](ead56a4))
* Custom type for output types ([c9ae9e9](c9ae9e9))
* Decorate parent decimal inputs ([9a7da40](9a7da40)), closes [unlight#113](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/113)
* Deprecation warnings ([55b21fd](55b21fd)), closes [unlight#161](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/161)
* Detect graphql type ([89a59cc](89a59cc)), closes [unlight#148](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/148)
* Detection property nullable type ([2121885](2121885))
* Do not generate undefined properties ([c7127a4](c7127a4))
* Dummy bump ([a161650](a161650))
* Duplicate import ([2a18c19](2a18c19)), closes [unlight#18](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/18)
* Emit metadata and enabled `emitSingle` cause TDZ issue ([0d89d81](0d89d81)), closes [unlight#16](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/16)
* Emit single with Prisma type ([94df9cf](94df9cf))
* Enum atomic operation are not processed ([43a2506](43a2506))
* Error too many open files ([2e67b25](2e67b25)), closes [unlight#162](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/162)
* Existence check of tsconfig ([4d523d2](4d523d2)), closes [unlight#23](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/23)
* Fix in getModelName helper ([190ab33](190ab33))
* Fix: Handle `FindUniq/First..OrThrowArgs` name ([0419d0d](0419d0d))
* Generate another commented class ([cc08dee](cc08dee))
* Generate correct json graphql type ([c6d8d46](c6d8d46))
* Generate distinct related enums with bound feature ([d055e3b](d055e3b))
* Generate enumerable filters ([9f35c9a](9f35c9a))
* **generate:** allow datamodels.type to be undefined ([faefc8f](faefc8f)), closes [unlight#106](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/106)
* Generator options: dasherizedName renamed to name ([c537340](c537340))
* Get graphql type for scalar list ([97a1ae4](97a1ae4)), closes [unlight#30](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/30)
* Get model name for CompoundUniqueInput ([f44aa85](f44aa85)), closes [unlight#53](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/53)
* Get model name from `{Model}AggregateArgs` type ([0703f7e](0703f7e))
* Getting json nullable enum ([d001714](d001714))
* Hide field for model type ([54571d2](54571d2))
* **hide field:** Fields in nested types ([2760d9e](2760d9e)), closes [unlight#80](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/80)
* **hide field:** Missing import of enum type ([b067142](b067142)), closes [unlight#73](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/73)
* **hide field:** Self relation field ([5cb4311](5cb4311)), closes [unlight#103](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/103)
* Json type changed to `Record<string, any>` ([2877be7](2877be7))
* Loading existing file ([fc19a03](fc19a03))
* Make fields in count output undefinable ([8e3d85c](8e3d85c))
* Make types same as in prisma ([1f5bc4e](1f5bc4e))
* Missing enum import type with enum filter object ([a5356c3](a5356c3)), closes [unlight#3](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/3)
* Missing import in hidden type ([29e5a8e](29e5a8e)), closes [unlight#62](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/62)
* Model types mismatch ([ffe70b6](ffe70b6)), closes [unlight#21](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/21)
* **mongodb:** Get matching input type from Json ([e16cad0](e16cad0))
* **mongodb:** Support composite types (behaves like model) ([d505ecb](d505ecb)), closes [unlight#99](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/99)
* More precise get model name ([96323c1](96323c1))
* Multiple namespace imports ([e096af0](e096af0)), closes [unlight#27](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/27)
* No atomic operations for scalar input list ([e55767b](e55767b))
* No atomic operations for scalar input list ([d32b03c](d32b03c))
* **other:** Decimal convert error ([67e6ccf](67e6ccf)), closes [unlight#113](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/113)
* **other:** Fail model with single id field in mongodb ([4d19e9a](4d19e9a)), closes [unlight#96](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/96)
* **other:** Ignore `@HideField()` for output count fields ([ce3eec2](ce3eec2)), closes [unlight#33](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/33)
* **other:** Makes proptype resolution behave like fieldtype ([850018a](850018a))
* Pin `ts-morph` to specific range ([d076fe9](d076fe9)), closes [unlight#146](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/146)
* Prisma client generator is optional ([4ce28f1](4ce28f1)), closes [unlight#25](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/25)
* **prisma:** Adapt generator to Prisma v2.13 ([d1ae8b1](d1ae8b1))
* Re-export iteration process fail ([bad1034](bad1034))
* Re-release 1.9.3 ([a52f31d](a52f31d))
* Regenerate enum ignoring existing values ([c581bc7](c581bc7)), closes [unlight#45](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/45)
* Regenerate model ignoring existing data ([62ffd83](62ffd83)), closes [unlight#45](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/45)
* Remove duplicated input types ([53d5721](53d5721))
* Remove empty input types ([20c4f46](20c4f46)), closes [unlight#26](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/26)
* Remove unused classes when both noAtomicOperations and emitSingle enabled ([41ce3c1](41ce3c1)), closes [unlight#89](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/89)
* Remove unused imports in generated files ([96ef374](96ef374))
* Removed unnecessary create enum from input type ([e6774ab](e6774ab))
* Renamed config option ([d989cfe](d989cfe))
* Save files without intermediate layer ([4a07bea](4a07bea))
* Scalar filters compatibility ([02acba8](02acba8))
* Select input type from multiple options ([81aeb02](81aeb02))
* Source file already exists error ([121a486](121a486))
* Switched to replace mode ([d04c3ef](d04c3ef))
* Type mismatch between prisma types ([b5587cd](b5587cd)), closes [unlight#4](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/4)
* Typescript property type now same as graphql type ([151d380](151d380))

### Performance Improvements

* Generation of inputs/outputs ([4604160](4604160))
* Removed unused code ([da6dbc0](da6dbc0))
* Removed unused code ([28f8784](28f8784))
* Slightly improved ([fd88dc9](fd88dc9))

### Miscellaneous Chores

* Bump version ([3267147](3267147))
* Removed deprecated setting `types_*` ([3491398](3491398))
* Renamed config option `atomicNumberOperation` to `noAtomicOperations` ([6078eb9](6078eb9))
* Update library to support to Prisma v4 ([1456303](1456303)), closes [unlight#123](https://github.com/resident-advisor/prisma-nestjs-graphql/issues/123)
* Update packages ([7e640a7](7e640a7))

### Code Refactoring

* Combine scalar filters ([789cfeb](789cfeb))
* Removed `renameZooTypes` config option ([71bfb68](71bfb68))
* Renamed token in `outputFilePattern` template ([95d4629](95d4629))
* Replace `matcher` by `outmatch` ([fa7c003](fa7c003))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants