Comments (9)
I think this has something to do with the compiling or the build process.
import CalendarView from 'vue-simple-calendar';
// this produces 'window not defined' in NuxtJS SSR
import CalendarView from '~/node_modules/vue-simple-calendar/src/CalendarView';
// this works in NuxtJS SSR
The main difference is that by default it pulls from the dist/
folder where the build process adds "window" implicitly, for what I assume is intended to be compatibility with multiple AMD/common.js early browser based module systems, where NuxtJS is better off importing the original ES6 to do it's own webpacking.
from vue-simple-calendar.
I took a look at the source code and couldn't really find the place where window is getting used.
It probably has to do with webpack and the targetLibrary option.
However I found a simple patch for this. Using the plugin is not enought as the application breaks not on render but on the import
// import Calendar from '@/src/components/dashboard/calendar/DashboardCalendarComponent.vue'
Therefore, this is how my components looks now:
export default {
name: 'p-page-dashboard-calendar',
components: {
'calendar': process.browser ? require('@/src/components/dashboard/calendar/DashboardCalendarComponent.vue').default : {},
'no-ssr': NoSSR
},
}
Not beautifull nor elegant, but gets it working.
from vue-simple-calendar.
Hi Borja,
Thanks for following up on this! I have the 3.0 branch open too and nearing completion, so you might want to check it as well. I'm not aware of anything in the component that would be incompatible with Nuxt, etc., but it's definitely not my area of expertise.
from vue-simple-calendar.
Good info... the current webpack build targets are based on some guidance I found online for making components that people could either script in directly (ES5 sans polyfills) or webpack (ES6).
I have no experience with Nuxt, and can't seem to find anything specific to how to make a component compatible with it by default. I'll probably migrate to vue-cli 3 as soon as it's out of beta, I wonder if it provides an OOTB webpack config that will work better with Nuxt?
from vue-simple-calendar.
Hi all! Great plugin, but i've got question about nuxt:
So i import calendar as suggest InstanceOfMichael:
import calendarView from '~/node_modules/vue-simple-calendar/src/CalendarView'
components: { calendarView }
<calendar-view event-content-height="2.2em" event-top="64px" :show-date="showDate" :events="events" @show-date-change="setShowDate" @click-event="clickEvent" class="theme-default" ></calendar-view>
And it works great on desktop, but i've got error on iPhones in Browserstock:
I use babel-polyfill in nuxt.config.js in vendor:
build: { vendor: [ 'babel-polyfill' ] }
Any suggestions will be great! Thanks!
from vue-simple-calendar.
It's definitely a babel-related issue, somehow your setup is not transpiling ES6-style function declarations. I've never used nuxt, so I don't have any more information. I'll leave this open in case anyone else can help.
from vue-simple-calendar.
Thanks for your answer! Can you suggest proper babel config for your plugin?
Thanks!
from vue-simple-calendar.
This is the .babelrc
what I use in the sample application, which, along with the browserslist
in package.json
, ensures the Vue code is compiled down to mundane ES5:
{
"presets": ["env"]
}
Unfortunately, I don't have any idea how one should go about configuring babel for Nuxt. It shouldn't be anything out of the ordinary, as many Vue components use the same ES6 features. If it turns out there are any hints or tweaks I can make that will make SSR easier, I'm happy to add them (or ideally accept PRs from people more familiar with that side of the Vue space).
from vue-simple-calendar.
Closing due to non-activity...
from vue-simple-calendar.
Related Issues (20)
- Bug when using item specific classes HOT 6
- do we support drag in batch? HOT 1
- delete this
- tooltip doesn't work HOT 2
- Misaligned row in demo HOT 4
- missing export in package.json HOT 3
- Clicking & URL issues HOT 2
- How can we get the selected object from the array? HOT 1
- Error of import HOT 3
- Feature Request: Show weekdays only HOT 1
- Error when importing vue-simple-calendar/dist/style.css HOT 3
- Can't use named slots with camelCase like dayContent HOT 2
- Time slots in weekly view HOT 1
- Week Numbers are off by 1 HOT 1
- Day order HOT 2
- v7.0 error [vite:resolve] Failed to resolve entry for package "vue-simple-calendar" HOT 2
- ReadMe update HOT 1
- Month skipping in month view HOT 2
- HTML tags in `title` attribute HOT 1
- Typescript error with moduleResolution: 'bundler'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-simple-calendar.