-
Notifications
You must be signed in to change notification settings - Fork 71
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
rpt2 not ignoring *.d.cts
and *.d.mts
files (resulting in Unexpected token
error)
#446
Comments
*.d.cts' or
*.d.mts`-files
Perhaps this is relevant: rollup/plugins#1480 |
*.d.cts' or
*.d.mts`-filesUnexpected token
when importing *.d.cts
or *.d.mts
files
So declaration files are not supposed to be directly imported in TS. TS picks them up without imports. See #273 for some more details. |
@agilgur5 well, that kind of goes without saying :) but I am not including the declaration files directly, nor is |
@phun-ky try explicitly including d.cts and d.mts: include: [ "*.ts+(|x)", "**/*.ts+(|x)", '**/*.d.cts', '**/*.d.mts' ] This will run them through typescript and I guess produce empty js. Somehow
|
Ah, ignore that -- this fixes the problem: include: [ "*.ts+(|x)", "**/*.ts+(|x)", '**/*.cts', '**/*.mts' ] |
@phun-ky could you try building your whole repo with master branch of the plugin? |
@ezolenko still got issues, sorry for the late reply! /home/alexander/Workspace/knowit/internal/devplatform-server-api/packages/middlewares/csp/src/index.ts → dist...
[!] (plugin rpt2) RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)
../../../node_modules/helmet/index.d.cts (3:5)
1: import {IncomingMessage, ServerResponse} from "http"
2:
3: type ContentSecurityPolicyDirectiveValueFunction = (req: IncomingMessage, res: ServerResponse) => string
^
4: type ContentSecurityPolicyDirectiveValue = string | ContentSecurityPolicyDirectiveValueFunction
5: interface ContentSecurityPolicyOptions {
at error (/usr/local/lib/node_modules/rollup/dist/shared/rollup.js:279:30)
at Module.error (/usr/local/lib/node_modules/rollup/dist/shared/rollup.js:13933:16)
at Module.tryParse (/usr/local/lib/node_modules/rollup/dist/shared/rollup.js:14644:25)
at Module.setSource (/usr/local/lib/node_modules/rollup/dist/shared/rollup.js:14246:39)
at ModuleLoader.addModuleSource (/usr/local/lib/node_modules/rollup/dist/shared/rollup.js:24211:20)
|
@phun-ky could you post verbose output when building with master branch and your rollup config if different from what you already posted? |
Here is the verbose output,
npm run build |
So this run succeeded? Try doing a clean build |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
What's weird is that this works like a charm: $ ts-node --esm --project tsconfig.json src/index.ts |
Any progress on this issue? :) |
@phun-ky the progress is slow :) Could you try Your example project compiles for me on that branch. |
@ezolenko yep! that worked like a charm! |
Ok, I'll make a release with the last few fixes |
In 0.35.0 now |
@ezolenko thanks for the great work! I really appreciate it! |
Ah, sorry for not checking this in more depth earlier! Was on my phone and just responded real quick to the title. We've had a lot of folks trying to import Glad that ezolenko had some time to spare and could help in more depth that same day! root cause analysis
So I did root cause this as I was curious how the heck that happened as that's definitely not correct behavior. Took me a bit to find Helmet's That is to say, the irony of incomplete branchesIn a bout of extreme irony, when I looked at my local code, I actually already had a similar line there 😵💫🤔 It turns out while I was attempting to fix #426 back in October (never quite finished that, partly because I was having trouble with Rollup ESM config), I made this commit on one of my branches containing the exact same line 😅 |
Unexpected token
when importing *.d.cts
or *.d.mts
files*.d.cts
and *.d.mts
files (resulting in Unexpected token
error)
Troubleshooting
Does
tsc
have the same output? If so, please explain why this is incorrect behaviorN/A
Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
yes
Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
https://stackblitz.com/edit/rpt2-repro-3j5vny?file=src%2Findex.ts,package.json,src%2Flib%2Findex.ts,README.md,tsconfig.json
What happens and why it is incorrect
Error is thrown, should have support for
*.cts
/*.mts
filesEnvironment
Ubuntu 22.04
Versions
:rollup.config.js
:tsconfig.json
:package.json
The text was updated successfully, but these errors were encountered: