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

feat: add Vite & Storybook; delete Parcel #31

Merged
merged 11 commits into from
May 26, 2023
Merged

feat: add Vite & Storybook; delete Parcel #31

merged 11 commits into from
May 26, 2023

Conversation

stevending1st
Copy link
Member

No description provided.

@stevending1st stevending1st requested a review from TechQuery April 29, 2023 15:48
@stevending1st stevending1st changed the title add Vite & add storybook [WIP] add Vite & add storybook Apr 29, 2023
@stevending1st stevending1st added the feature New feature or request label Apr 29, 2023
@stevending1st stevending1st changed the title [WIP] add Vite & add storybook add Vite & add storybook May 2, 2023
@stevending1st stevending1st changed the title add Vite & add storybook feat: add Vite & add storybook & delete parcel May 2, 2023
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
tsconfig.build.json Outdated Show resolved Hide resolved
.storybook/main.ts Outdated Show resolved Hide resolved
.storybook/preview.ts Outdated Show resolved Hide resolved
stories/Avatar.stories.ts Outdated Show resolved Hide resolved
vite.config.ts Outdated Show resolved Hide resolved
@stevending1st stevending1st requested a review from TechQuery May 26, 2023 18:17
@TechQuery TechQuery changed the title feat: add Vite & add storybook & delete parcel feat: add Vite & Storybook; delete Parcel May 26, 2023
@TechQuery TechQuery merged commit e55f6b3 into master May 26, 2023
@TechQuery TechQuery deleted the vite branch May 26, 2023 19:49
@TechQuery
Copy link
Member

TechQuery commented Jun 9, 2023

Vite bundles import() into UMD without async loading, which is different with ESM:

Source code

const Map = lazy(() => import('./core'));

Next.js 12 error

Server Error
ReferenceError: window is not defined

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///D:/Work/idea2app/IdeaMall/PWA/node_modules/.pnpm/leaflet@1.9.4/node_modules/leaflet/dist/leaflet-src.js (230:19)
<unknown>
file:///D:/Work/idea2app/IdeaMall/PWA/node_modules/.pnpm/leaflet@1.9.4/node_modules/leaflet/dist/leaflet-src.js (7:66)
Object.<anonymous>
file:///D:/Work/idea2app/IdeaMall/PWA/node_modules/.pnpm/leaflet@1.9.4/node_modules/leaflet/dist/leaflet-src.js (10:3)
Module._compile
node:internal/modules/cjs/loader (1196:14)
Object.Module._extensions..js
node:internal/modules/cjs/loader (1250:10)
Module.load
node:internal/modules/cjs/loader (1074:32)
Function.Module._load
node:internal/modules/cjs/loader (909:12)
Module.require
node:internal/modules/cjs/loader (1098:19)
require
node:internal/modules/cjs/helpers (108:18)
Object.<anonymous>
file:///D:/Work/idea2app/IdeaMall/PWA/node_modules/.pnpm/@react-leaflet+core@1.1.1_leaflet@1.9.4_react-dom@17.0.2_react@17.0.2/node_modules/@react-leaflet/core/cjs/dom.js (8:16)

Bundle structure

image

Possible solutions

  1. https://babeljs.io/docs/babel-plugin-transform-modules-umd
  2. https://vitejs.dev/guide/features.html#dynamic-import
  3. https://stackoverflow.com/a/76303955
  4. https://sambitsahoo.com/blog/vite-code-splitting-that-works.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants