Comments (5)
Thanks for filing issue! I'll need a little more information if that's okay: what's your Node version? Is your project a CommonJS module or ES module?
from scroll-js.
Hmm I'm not too familiar with how Vite resolves modules. But it looks like Vite is attempting to build scroll-js as a CommonJS module instead of ES module. scroll-js exposes multiple dist files that can be used, depending on how your project is set up.
See main
and module
fields here. If your project is an ES module, Vite should be resolving to the dist/scroll.js
file in the module
field instead of the dist/scroll.common.js
file in the main
field. (common.js
extension just means it's meant for a CommonJS project)
Does that help at all? If not, I can try to pull Vite down and import it to see if I can reproduce.
from scroll-js.
Hey, thank you for taking the time and looking into it!
I’m taking the ES route and tested various node versions between 16.15.x
and 18.4.x
all throwing the same error.
The full error report looks like:
Cannot find module 'core-js/modules/es.object.to-string.js' imported from '[...]/node_modules/scroll-js/dist/scroll.common.js'
Error: Cannot find module 'core-js/modules/es.object.to-string.js' imported from '[...]/node_modules/scroll-js/dist/scroll.common.js'
at viteResolve ([...]/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:50310:25)
at Function.<anonymous> ([...]/node_modules/vite/dist/node/chunks/dep-8f5c9290.js:50327:28)
at Module._load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at require (node:internal/modules/cjs/helpers:102:18)
at [...]/node_modules/scroll-js/dist/scroll.common.js:10:83
at Object.<anonymous> ([...]/node_modules/scroll-js/dist/scroll.common.js:13:3)
at Module._compile (node:internal/modules/cjs/loader:1112:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1166:10)
at Module.load (node:internal/modules/cjs/loader:988:32)
I am absolutely not sure, it can totally be a problem on my side, but yet again I did nothing more than importing the module... Are there any requirements?
from scroll-js.
Hey @moritzebeling just checking in. Hopefully you found a resolution for your issue. I'll leave this open for a few more days. If I don't hear back from you, I'll assume all is well and close issue. Thanks again for your contributions!
from scroll-js.
Hey Mark, thank you very much for checking back in. I was trying out several other plugins and now wanted to try yours once again because it seems to be one of the very few that support SSR and duration control :)
I tried with the "type": "module"
and several Vite options but couldn’t solve the error.
When trying to import directly from the source file scroll-js/dist/scroll.js
it said unexpected keyword "export"
, which I found very weird.
I then copied the file dist/scroll.js
from the node_modules
folder into my project and now import directly and funnily enough it now works:
import { scrollTo } from './scroll.js';
Unfortunately I don’t know enough about Vite, Rollup or CommonJS to really pinpoint how this could be resolved. It really only seems to be a configuration issue.
And I also know that this is not the idea of open source modules, but I will now use is as a temporary workaround. Thank you!
from scroll-js.
Related Issues (20)
- Errors with brunch HOT 6
- Container.contains is not a function HOT 2
- Duration: 0? HOT 8
- Offset option HOT 17
- Massive NPM package HOT 3
- Stop scrolling immediately. HOT 4
- Scroll start always from the top of the page rather than from the current position HOT 5
- Scrolling always starts at the top for Chrome and Firefox HOT 4
- other easing options HOT 3
- Support more ScrollIntoViewOptions per specification
- Remove support for instant behavior
- Holp to support `top` into ScrollIntoViewOptions HOT 1
- Behavior of `behavior` HOT 2
- Why does this package has a minimal node engine version HOT 6
- IE11 Support HOT 3
- On nextjs it runs in development mode. HOT 2
- Feature Request: `cancel` method
- Feature Request: `scrollBy` method
- scrollIntoView not working in IE HOT 4
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 scroll-js.