Open H01001000 opened 11 months ago
Hi @H01001000 I don't know if I understand your issue correctly Has Commonjs been generated for you?
Mainly about importing, esm need import extension, where input and builder file I can manually add .js at back, but for example utils and object.base don’t have import extension
You are needing to replace imports with -.js
?
For example:
import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils';
to
import { defineMutation, defineMutationFunction, defineMutationPrismaObject } from '../../utils.js';
?
Although I don't understand exactly why, if this is the case perhaps you could use the configs.global.replacer
setting to define a function for this
@H01001000 If I understand correctly the way your project is configured, you need the .ts at the end of each import, right? Does the replacer solve your case?
@Cauen In simple words,
ESM can works with
// Same with TypeScript targeting ESM
import { } from "./script.js"
import { } from "./dir/index.js"
CommonJS can works with both
const { } = require("./script");
const { } = require("./script.js");
const { } = require("./dir");
const { } = require("./dir/index.js");
// TypeScript target CJS
import { } from "./script"
import { } from "./script.js"
import { } from "./dir"
import { } from "./dir/index.js"
@Cauen sorry for the late reply, it should Besides it seems that because this repo's target is commonJS, an explicit .cjs extension is needed for pothos.config.xxx
for now, I did is generate it as a separate package with type commonJS, and import it to main pkg
p.s. is type checking possible? tsc with skipLibCheck: false
results in run out heap or run forever. there also seems some type error
Our lib today generates typescript code, right? I can't quite understand how these extensions cause any problems in your project.
Could you send me some minimal example of the problem you have there?
In the develop branch, i've created an example with dev
, build
and start
commands
https://github.com/Cauen/prisma-generator-pothos-codegen/blob/develop/examples/inputs-simple-sqlite/package.json
Is the problem you face with the build?
@Cauen MRE: add "type": "module"
to package.json
Hi @H01001000 Can you please propose the solution you need as a PR?
sure, btw what yarn version you using? it seem the yarn is not up to date, want we pr it?
Feel free to update it :)
My version: 1.22.21
@Cauen btw I found out that when simple is false, tsc runs out of the heap when compiling my input.ts file. Is it possible to split the input file for each model?
Hello, it is not mentioned in the README, but I wonder does it supports outputting ESM module?