Skip to content
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

Esmodule options in rollup output is always undefined #469

Closed
etienne-dldc opened this issue Jan 29, 2020 · 7 comments · Fixed by #555
Closed

Esmodule options in rollup output is always undefined #469

etienne-dldc opened this issue Jan 29, 2020 · 7 comments · Fixed by #555
Labels
kind: bug Something isn't working

Comments

@etienne-dldc
Copy link
Contributor

Hi,

While working on #468 I noticed this line of code

esModule: tsconfigJSON ? tsconfigJSON.esModuleInterop : false,

But esModuleInterop is a compiler option so I guess it should be

esModule: Boolean(tsconfigJSON?.compilerOptions?.esModuleInterop)

I can create a PR to fix this I just want to be sure that I'm not missing something here...

@agilgur5
Copy link
Collaborator

Oh sh*t, you're right, that's actually my code from #327 😨 . We don't have automated tests for tsconfig properties (we should! for #468 too preferably), but I actually have a fork of TSDX I used specifically for this feature and it worked there.... 😖 🤔 🤔

Let me take a look at it when I get the chance. This syntax is preferred though.

I'm also working on adding tests for custom babel config (c.f. #443 ); custom tsconfig is actually easier (no new dependencies).

@agilgur5
Copy link
Collaborator

agilgur5 commented Jan 30, 2020

Ok, dug into this and found some strange results. The library I initially wrote this fix/feature for does indeed have Object.defineProperty(exports, '__esModule', { value: true }); in its dist/ output, see https://unpkg.com/mst-persist@0.1.3/dist/mst-persist.cjs.development.js. So does https://unpkg.com/jest-without-globals@0.0.2/dist/jest-without-globals.cjs.development.js. Both have tsconfig.compilerOptions.esModuleInterop set to true.

So did some further sleuthing and some testing and turns out esModuleInterop is actually almost always true now 😅 😅. To be specific, tsconfigJSON ? tsconfigJSON.esModuleInterop : false always evaluates to undefined -- and rollup has output.esModule set to true by default. It'll only be set to false if there is no tsconfig.json.

So yea, a PR would fix this. I think a test should re-use the directory in #468 (which might take a bit to get merged as Jared will likely be the one to merge it), and then could do something like:

const buildExports = require('../stage-build/dist/index.js');
expect(buildExports.__esModule).toBe(true);

@etienne-dldc
Copy link
Contributor Author

OK, I'll wait for #468 to be merged then

@agilgur5
Copy link
Collaborator

👍 Do you think you can rename this issue in the meantime? Just to avoid any confusion

@etienne-dldc etienne-dldc changed the title Esmodule options in rollup output is always false Esmodule options in rollup output is always undefined Jan 30, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 9, 2020

@etienne-dldc now that #468 is merged would you like to PR the fix to this? I can merge that in a lot faster myself now that I'm a collaborator

@etienne-dldc
Copy link
Contributor Author

Sorry for the late response...

Thanks for taking care of this 😃

@agilgur5
Copy link
Collaborator

agilgur5 commented Mar 11, 2020

No need to apologize, 2 days to respond is pretty normal. I just wanted to get all the tsconfig changes & tests done in one go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants