fix(v2): fix plugin-ideal-image breaking website (exports not defined) #2074
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
First of all, #2011 broke the website
The netlify preview of that PR is also broken.
Why is this happening ?
We're using a bundler like Webpack that squeezes those modules into a single minimized javascript file, so you want to keep that line as-is.
When Typescript compiles into javascript, it adds the line Object.defineProperty(exports, "__esModule", { value: true }); which causes an error Uncaught ReferenceError: exports is not defined or something similar in your browser's console.
And we're doing the TS compilation wrong !
The current Typescript compiler setting of that pr also assumes you are writing a Node.js application, which is wrong. You should use the right tscompiler setting for DOM. But its slightly complicated because
src/index.js
is Node.js andsrc/theme/IdealImage.tsx
is reactjs (not nodejs).Anyway, I'm gonna revert the theme component conversion back to JS and just copy it as it is. The types isn't exactly accurate anyway.
This is an urgent fix because v2 site is broken now. No SPA load
I've deprecated the package in npm
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan