Comments (13)
Perhaps you need to use global variables, such as spica
, localsocket
and pjax-api
for endpoints. I am currently not using Browserify but I'm considering using it.
from pjax-api.
Thank you for the quick reply! So like this?
import spica from 'spica';
import localsocket from 'localsocket';
import Pjax from 'pjax-api';
It seems I’m still getting the same error.
from pjax-api.
https://github.com/thlorenz/browserify-shim may resolve your problem.
from pjax-api.
So I’m using browserify-shim and I’ve set it up like this:
main.js
:
var spica = require('spica');
var localsocket = require('localsocket');
import Pjax from 'pjax-api';
package.json
:
"browserify": {
"transform": [
[
"babelify",
{
"presets": [
"es2015"
]
}
],
"browserify-shim"
]
},
"browserify-shim": {
"./node_modules/spica/dist/spica.min.js": "global:spica",
"./node_modules/localsocket/dist/localsocket.min.js": "global:localsocket"
}
gulpfile.js
:
gulp.task('scripts', function () {
var b = browserify({
entries: ['src/scripts/modernizr.js', 'src/scripts/main.js'],
debug: true
}).transform(babelify, { presets: ["latest"] });
return b.bundle()
.pipe(source('main.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
// Add transformation tasks to the pipeline here.
// .pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('build/js/'));
});
Now I get the error: pjax-api.js:24Uncaught Error: Cannot find module 'spica'
. I guess this is not the correct way to require or import spica/localsocket?
from pjax-api.
I published the new version now. pjax-api
has been using Browserify since 3.4.0, also the depended libraries too. You should be able to build it.
from pjax-api.
@falsandtru thank you so much for all your help and hard work!
I’ve updated the above code, still using browserify-shim
, but with the new versions of spica, localsocket, and pjax-api. Main.js only has the import statement for pjax-api. The import seems to be working correctly!
However, I’m getting a different error now:
tinymce.js:41629 Uncaught TypeError: _pjaxApi2.default is not a constructor
at Object.5.jquery (http://localhost:8000/static/articles/build/js/main.js:60706:1)
at s (http://localhost:8000/static/articles/build/js/main.js:1:254)
at e (http://localhost:8000/static/articles/build/js/main.js:1:425)
at http://localhost:8000/static/articles/build/js/main.js:1:443
from pjax-api.
Thanks for the report. That is because __esModule
flag is missing. I fixed it in 3.4.1. The same is true for other depended libraries.
from pjax-api.
@falsandtru thank you again!
I’ve updated to the new versions, but am still getting an error:
My code and the error are here and the full main.js is here. Maybe it's an issue with how I'm doing the require statements?
from pjax-api.
Probably you need to update other libraries such as spica and localsokcet. What version of libraries are you using?
from pjax-api.
I’m using these versions:
Robins-MacBook-Pro:articles robin$ npm update spica localsocket pjax-api
[email protected] /Users/robin/work/2016-06-04_togethere/togethere/articles/static/articles
├── [email protected]
├── [email protected]
└── [email protected]
(forgot to update package.json in that earlier gist, sorry!)
from pjax-api.
Now you cannot use browserify-shim for spica and localsocket. So you need to remove the following code.
"browserify-shim": {
"./node_modules/spica/dist/spica.min.js": "global:spica",
"./node_modules/localsocket/dist/localsocket.min.js": "global:localsocket"
}
from pjax-api.
I’ve uninstalled browserify-shim and made sure it’s not being used, but it looks like I’m still getting the same issue... code here.
Sorry to be such a pain in the ass. Maybe I’m doing things wrong in the way I require the libraries?
from pjax-api.
Seems like this is a difficulty of Browserify. We cannot directly bundle another browserified library. If you know another library which bundled browserified library, let me know that library.
from pjax-api.
Related Issues (20)
- Interop with Webpack HOT 9
- End of support for Edge browser HOT 1
- Not working on page with external Javascript HOT 5
- merge laravel pjax error HOT 1
- Animation between page navigation HOT 2
- Uncaught TypeError HOT 4
- Hello HOT 1
- ファイルサイズの削減のお願い HOT 3
- Hello, HOT 1
- Error when Cache-Control is not set HOT 2
- IE11 support - will running through babel solve it? HOT 5
- Adding more events, preventing unload on condition HOT 4
- Ajax POST method become GET HOT 1
- Support Firefox add-ons execution environment HOT 9
- The content of ajax request, click back will disappear HOT 1
- How do you use the sequence property? HOT 12
- Forms with POST method doesn't work HOT 2
- Example on how to setup backend HOT 4
- how to keep css throught pages? HOT 2
- I can not request same url after upgrading from 3.35.3 to 3.38.1 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 pjax-api.