ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

test: dogfood rpt2 as `configPlugin` w/ `rollup.config.ts` #460

Open agilgur5 opened 1 year ago

agilgur5 commented 1 year ago

Summary

Dogfood rpt2 more by using it as a configPlugin on our own internal rollup.config.ts

Details

Motivation

TS Fixes

ESM Fixes

Misc

456 was split out of this as it took me quite a while to get builds to pass

agilgur5 commented 1 year ago

As this is a breaking change due to use of createRequire, should probably go out in the same release as #458

agilgur5 commented 1 year ago

Tests are failing due to use of createRequire... this might require bumping ts-jest 😕

ezolenko commented 1 year ago

I'm also getting an error on Windows trying one of the build_self scripts, a rollup issue?

> rollup -c rollup.config.self.ts --configPlugin ./build-self/index.mjs="{ tsconfigOverride: { compilerOptions: { resolveJsonModule: true } } }"

[!] Error: Cannot load plugin "C:\sandbox\other\rpt2\rollup-plugin-typescript2\build-self\index.mjs": Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'.
Error: Cannot load plugin "C:\sandbox\other\rpt2\rollup-plugin-typescript2\build-self\index.mjs": Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'.
    at loadAndRegisterPlugin (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\shared\loadConfigFile.js:508:23)
    at addPluginsFromCommandOption (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\shared\loadConfigFile.js:458:17)
    at getDefaultFromTranspiledConfigFile (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\shared\loadConfigFile.js:583:5)
    at loadConfigFile (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\shared\loadConfigFile.js:565:11)
    at Object.loadAndParseConfigFile (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\shared\loadConfigFile.js:545:21)
    at getConfigs (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\bin\rollup:1691:39)
    at runRollup (C:\sandbox\other\rpt2\rollup-plugin-typescript2\node_modules\rollup\dist\bin\rollup:1665:43)
agilgur5 commented 1 year ago

Dang thought we were past all Windows pathing issues 😅

Looks like something is expanding/converting the path in a way Rollup doesn't like ./build-self/index.mjs -> C:\sandbox\other\rpt2\rollup-plugin-typescript2\build-self\index.mjs. I'm not sure if Rollup is doing that expansion or something else (NPM as it's a script?), but I would think Rollup should know how to interpret that correctly 🤔 The error message makes it sound like potentially an ESM spec issue. So if Rollup is the one expanding it, it's expanding incorrectly for ESM. If it's NPM or something else expanding, that's a bit more of a head-scratcher