Skip to content

refactor: Migrate to Vite#31

Merged
null2264 merged 69 commits intodevelopfrom
refactor/vite
Sep 27, 2023
Merged

refactor: Migrate to Vite#31
null2264 merged 69 commits intodevelopfrom
refactor/vite

Conversation

@null2264
Copy link
Owner

@null2264 null2264 commented Sep 23, 2023

@null2264 null2264 added the enhancement New feature or request label Sep 23, 2023
@null2264 null2264 self-assigned this Sep 23, 2023
@null2264
Copy link
Owner Author

null2264 commented Sep 24, 2023

I once again, hit CSP wall... Vite doesn't have __webpack_nonce__ equivalent, even their own script module (I guess it's called "preload" module?) doesn't work because it's blocked by strict CSP. I need to find a workaround for this... again...

REF: vitejs/vite#9719

Update: Fixed by using vitejs/vite#9719 (comment) (plugin workaround) and vitejs/vite#11864 (patch). Also, important to note that the CSP issue seems to only happened on dev env, __webpack_nonce__ still usable in prod.

@null2264
Copy link
Owner Author

null2264 commented Sep 25, 2023

Everything seems to work fine, well except on prod... it keep throwing Uncaught TypeError: ct is null for some reason.

Caused by Goober:
local (node_modules): t.data=t.data
remote (prod): ct.data=ct.data
code (https://github.com/cristianbote/goober/blob/a849b2d644146d96fa1dd1c560f6418ee1e1c469/src/core/update.js#L20-L25):

export let update = (css, sheet, append, cssToReplace) => {
    cssToReplace
        ? (sheet.data = sheet.data.replace(cssToReplace, css)) // the problematic part, sheet is null
        : sheet.data.indexOf(css) === -1 &&
          (sheet.data = append ? css + sheet.data : sheet.data + css);
};

Could be related to cristianbote/goober#500

Update: For some reason /*goober*/ inside style #_goober got stripped on prod build, caused sheet to be null

Update: Fixed by patching

@null2264
Copy link
Owner Author

null2264 commented Sep 26, 2023

Another error after goober's null sheet, this time it's require is not defined, after some investigation it seems to be caused by react-hotkeys, the library is no longer maintained, potential replacement: https://github.com/JohannesKlauss/react-hotkeys-hook

Update: Fixed, we'll use GitHub's hotkey

@null2264
Copy link
Owner Author

Most if not everything is working now, should be ready to be merged.

@null2264 null2264 marked this pull request as ready for review September 27, 2023 10:04
@null2264 null2264 merged commit 707275f into develop Sep 27, 2023
@null2264 null2264 deleted the refactor/vite branch October 15, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webpack -> Vite

1 participant