Comments (12)
Hi @jesperwestlund1,
Can you share your complete code so I can have a look and spot the issue ?
I might need to see the code where you use Highway and the Gulp task throwing the error as well.
Thanks,
Anthodpnt
from highway.
Hi @Anthodpnt , yes of cource.
main.js
import Highway from '@dogstudio/highway'
console.log('hello');
javascript gulp.
'use strict';
var gulp = require('gulp');
var watchify = require('watchify');
var browserify = require('browserify');
var babelify = require('babelify');
var changed = require('gulp-changed');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var gutil = require('gulp-util');
var assign = require('lodash.assign');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var customOpts = {
entries: ['assets/js/main.js'],
debug: true
};
var opts = assign({}, watchify.args, customOpts);
var bundler = watchify(browserify(opts).transform(babelify, {presets: ["es2015"]}));
var destination = './build';
gulp.task('js', bundle);
bundler.on('update', bundle);
bundler.on('log', gutil.log);
function bundle() {
return bundler.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('app'))
.pipe(changed(destination))
.pipe(rename({ extname: '.js' }))
.pipe(gulp.dest(destination))
.pipe(buffer())
.pipe(uglify().on('error', gutil.log))
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(destination))
}
from highway.
Hello @jesperwestlund1,
In order to test faster & have the most similar environment / configuration, could you zip your test & drop it here ? This way we can try to reproduce & solve your issue in the best conditions :-)
( delete the node_modules, just keep the package.json )
from highway.
Hi @ThaoD5 , Yes here you have!
from highway.
@jesperwestlund1,
I think the issue comes from the configuration of babelify in your package.json
.
For now only the files coming from assets/js
are compiled by babelify using presets-2015
. This means that Highway is never compiled since it comes from the node_modules
folder and it needs to pass through babelify as explained in the documentation if you want to support all browsers.
I guess you can easily fix this issue by changing the only
parameter of babelify with a regex including highway like /(assets\/js|node_modules\/@dogstudio\/highway\/dist)/
or something.
Or you can just add Highway in your assets/js/lib
folder like you do for GSAP.
Let me know if the issue came from this configuration :).
Best regards,
Anthony
from highway.
@Anthodpnt Hmm... okey, I tried to import it manually like you say, I put highway.js in assets/js/lib
then I import it like this in main.js
import highway from './lib/highway'
and this is how it's look in my package.json
"browser": {
"config": "./assets/js/config.js",
"highway": "./assets/js/lib/highway.js",
"gsap-splitext": "./assets/js/lib/gsap/src/uncompressed/utils/SplitText.js",
"gsap-scrollto": "./assets/js/lib/gsap/src/uncompressed/plugins/ScrollToPlugin.js"
},
But it's not working.. the gulp file will not be completed.. when I run gulp
from highway.
@jesperwestlund1 Do you use babelify on Highway ?
from highway.
@Anthodpnt babelify
from highway.
@jesperwestlund1,
The problem is that Babelify skips all node_modules
folders but since Highway is part of the node_modules
folders it's never transpiled into ES5 by Babelify.
Based on this explanation you have to change a bit your javascript.js
file with this:
// YOUR CODE
var bundler = browserify(opts).transform(babelify, {
global: true,
ignore: /\/node_modules\/(?!@dogstudio\/highway\/)/,
presets: ["env"]
});
// YOUR CODE
This will ignore all node_modules
folders except for node_modules/@dogstudio/highway
. So now Highway should be properly transpiled into ES5. This will solve the initial issue about Renderer
apparently.
When testing I came across other errors I managed to fix by installing babel-preset-env
instead of babel-preset-es2015
. Check the Babel documentation about this preset.
Finally, there is one last thing to do that I couldn't manage to fix with your stack. You need to import babel-polyfill
in you main.js
file. But for a reason I ignore this always throw an Unexpected end of input
error in the browser console... Check the Babel documentation about this polyfill.
Unfortunately I'm not used to work with Browserify and Babelify so you'll have to find a way to import babel-polyfill
properly at the top of the main.js
and fix the Unexpected end of input
error by yourself.
I hope that it will help you and don't hesitate to keep me in touch.
Best regards,
Anthodpnt
from highway.
@jesperwestlund1
An easier solution to properly transpile Highway to ES5 using Babelify is to:
- Put Highway in your
assets/lib
folder - Add
"highway": "./assets/js/lib/highway/highway.js",
in thepackage.json
like earlier - Install
babel-preset-env
(check the documentation) - Update your
javascript.js
file with this:
// YOUR CODE
var bundler = browserify(opts).transform(babelify, { presets: ["env"] });
// YOUR CODE
This should also fix the initial Renderer
issue from this thread.
But again you'll still have to add babel-polyfill
and fix the error explained in previous comment.
Best regards,
Anthodpnt
from highway.
@Anthodpnt Yes! thanks! that did the work! 👍
from highway.
@jesperwestlund1 Perfect, I close the issue then!
from highway.
Related Issues (20)
- Javascript functions doesn't works on the second time HOT 1
- Locomotive scroll not updating after page transition HOT 3
- I can't get the HIGHWAY.redirect() to work HOT 1
- Updating CSS for incoming page – (Highway maintains the outgoing page's CSS) HOT 5
- data-transition attribute no longer works in 2.2.2 HOT 2
- Update /refresh/bind links dynamically created with javascript HOT 1
- New href with highway HOT 13
- Adding additional headers to page requests
- Add index.d.ts file for better IDE typehinting
- back/forward buttons pressed during transition break the website
- Facebook Pixel Tracking HOT 3
- Fatal error on transition to mismatching URL scheme, while remaining on the same domain
- Can't work with CDN
- Improper use of DOM events
- Highway not working with DOM elements rendered by javascript HOT 1
- H.redirect always refresh page HOT 1
- Help
- H is undefined HOT 1
- Navigation with parameters and anchor not working
- Javascript not working after page transition HOT 2
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 highway.