Open agilgur5 opened 1 year ago
As this is a breaking change due to use of createRequire
, should probably go out in the same release as #458
Tests are failing due to use of createRequire
... this might require bumping ts-jest
😕
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)
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
Summary
Dogfood rpt2 more by using it as a
configPlugin
on our own internalrollup.config.ts
Details
Motivation
use rpt2 as a
configPlugin
within our own build process, as well as to build itselfwe don't have any tests for
configPlugin
s, and it's a Rollup CLI option, so this is one of the few ways to test it_build-self
script so we don't need to type/repeat as much (or have as much potential for mistakes)TS Fixes
replace the unmaintained
rollup-plugin-re
w/@rollup/plugin-replace
rollup-plugin-re
hasn't had a commit in ~5 years and doesn't have typings (natively or in DT)fix the usage of the
resolve
plugin as it didn't type-check/had outdated usageESM Fixes
need to use
createRequire
in ESM mode@types/node
to support the types for that as wellfix
fs-extra
error due to it being CJSrequire("package.json")
->import
resolveJsonModule
toconfigPlugin
tsconfigOverride
to handle thisconfigPlugin
, not everything else, so not added totsconfig.json
output as
build-self/index.mjs
instead ofbuild-self/dist/rollup-plugin-typescript2.es.js
index.d.ts
Misc
456 was split out of this as it took me quite a while to get builds to pass