-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Browserify based project dependencies issue #48
Comments
Try changing
to .transform(babelify.configure(
ignore: "bower_components",
extensions: ['.js']
sourceMapRelative: "./#{config.appDir}"
)) |
That works perfectly. Ashamed that I hadn't thought of before. Thank you!) And minor question. Is there a way not to use 'remapify' and replace it with some integrated solution? |
I'm not familiar with remapify, what exactly do you want to do? |
It's just for using relative paths inside the modules. import View from 'scripts/views/view' instead of path from Node.js rootPath: import View from '../../scripts/views/view' |
There's the option |
Could you please provide short example of this option using? It still doesn't work. ( |
Just realised that you wont be able to do what you want since there's no |
Looks like @sebmck It would've been possible before by returning an absolute path from @maratfakhreev Usage for you should be something like this I think: var aliases = {
scripts: '/abs/path/to/scripts',
templates: '/abs/path/to/templates/',
};
babelify.configure({
resolveModuleSource: function (id, parent) {
var matches = id.split('/');
if (aliases[matches[0]]) {
id = id.replace(
matches[0],
path.relative(parent, aliases[matches[0]]))
);
}
return id;
},
}) As you probably know, remapify has all sorts of problems. Another alternative that may work for you is my pathmodify browserify plugin. ( var pathmod = require('pathmodify');
// ...
.plugin(pathmod(), {mods: [
pathmod.mod.dir('scripts', '/abs/path/to/scripts'),
pathmod.mod.dir('templates', '/abs/path/to/templates'),
]} |
Ohh, I solved this problem some time ago, here my working config (as you can see I don't use remapify or smth like it): var gulp = require('gulp');
var rename = require('gulp-rename');
var browserify = require('browserify');
var transform = require('vinyl-transform');
var browserifyShim = require('browserify-shim');
var jadeify = require('jadeify');
var babelify = require('babelify');
var watchify = require('watchify');
var notify = require('gulp-notify');
var cordovaPrepare = require('../helpers/cdv');
var config = require('../config');
var entryPoint = "./" + config.appDir + "/scripts/main.js";
gulp.task('browserify', function() {
var bundler = browserify({
cache: {},
packageCache: {},
fullPaths: true,
debug: config.isDevelopment(),
extensions: ['.jade', '.js'],
entries: entryPoint,
paths: ["./" + config.appDir]
})
.transform(browserifyShim)
.transform(jadeify)
.transform(babelify.configure({
ignore: [
'bower_components',
'vendor/scripts'
],
sourceMapRelative: "./" + config.appDir
}));
function bundle() {
var bundleTransform = transform(function(filename) {
return bundler.bundle();
});
return gulp.src(entryPoint)
.pipe(bundleTransform)
.on('error', notify.onError())
.pipe(rename({basename: 'application'}))
.pipe(gulp.dest(config.publicDir))
.on('data', cordovaPrepare);
};
if (config.isDevelopment()) {
watchify(bundler).on('update', bundle);
};
return bundle();
}); Btw thank you guys (@sebmck, @jmm) for supporting and for good advices. If there no questions you could close the issue. |
I'm trying to replace CoffeeScript to ES6 in my project. It's Cordova based project which uses gulp + bower + browserify + marionette.js and some other libs. I ran into a problem, third-party libraries (for example Backbone) complain on 'use strict'. If I'm not mistaken It's because browserify compile project into one file and wraps each dependency with 'use strict' mode. How can I fix it? Here is my browserify config and apps start file. This configuration with coffeify works correct.
For proper libraries connection I'm using 'browserify-shim' package.
Here the error:
The text was updated successfully, but these errors were encountered: