Closed benallfree closed 7 months ago
@benallfree how do i do that?
Yeah that's a little difficult because you can't npm install
a package from a monorepo. I'm looking into it more.
@urizennnn you can try this, it's a build from this PR branch
npm i plop-4.0.1.tgz
can it be installed globally?
Yes you can try that
Yes you can try that
The big problem with this approach and the reason I never merged #397, despite having the ability to is that we need a compiler flag to opt out of the TSX loader so people can use their own to support path flags and other tsconfig options
That + docs and tests that we'd need to merge this PR
Yeah I experimented with integrating more with rechoir but couldn't get the ts test to pass even though yarn plop
ran successfully.
Can you say more about opting out of the tsx loader?
For now #423 is working for me:
"scripts": {
"plop": "cross-env NODE_OPTIONS='--import tsx' plop --plopfile=plopfile.ts",
}
If you'd like me to work more on this and get tests passing, I'm happy to keep going. This seems like something Liftoff should have working OOTB, but maybe I don't understand. I thought Liftoff was supposed to install other handlers on demand.
This works:
const Liftoff = require('liftoff')
const Hacker = new Liftoff({
name: 'hacker',
processTitle: 'hacker',
moduleName: 'hacker',
configName: 'hackerfile',
extensions: {
'.ts': 'tsx/dist/loader.cjs',
},
v8flags: ['--harmony'], // or v8flags: require('v8flags')
})
Hacker.prepare({}, function (env) {
Hacker.execute(env, async (env) => {
await import(env.configPath)
})
})
Right, I ran into many of the same problems with Liftoff, myself. I think there was some reason between plop CLI and node-plop that wasn't synced leading to the mismatched behavior.
The problems with opting out come from "How do I use one TSconfig for X but another for Plop and both have paths that inherit from a base config" kinda deal.
Tbh I REALLY like your NODE_OPTIONS userland fix to this problem, rather than trying to inhouse all of the edgecases. What if we just make a PR to add the explainer on how to do that on our website instead of trying to make it a feature?
Suits me perfectly, and it also is kind of a forward-looking approach since that --import
and esm support seems to be stabilizing.
Shall I send a docs PR?
Let's do it! Thanks for your understanding and help! ✨
Closing in favor of #428
Closes:
297
397
426