Comments (3)
How odd!
I haven't looked too hard at this but in your gulpfile, try only including
main.ts in your bundle.add call. All Browserify needs is the single entry
point into your code; it walks the dependencies automatically. Including
helper.ts as an entry might be messing with something. Though I wouldn't
expect quite that output...
On Apr 3, 2015 1:47 PM, "Mike Wilcox" [email protected] wrote:
Hi @smrq https://github.com/smrq,
First, thanks for this project!
I am not sure if this is an issue with browserify, tsify, typescript, or
if I am just doing something wrong. Basically, what I am seeing is that
when I try to import an exported class using require(), the module i am
trying to import is linked to as undefined. I am not intimately familiar
with browserify inner-workings, but if I change this undefined to a 1, I
see that the code runs fine! See below where the './components/helper' is
linked to as undefined:bundle.js:
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i
(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var Helper = (function () {
function Helper() {
}
Helper.prototype.sayHello = function () {
console.log('hello from the helper!');
};
return Helper;
})();module.exports = Helper;},{}],2:[function(require,module,exports){/// var Helper = require('./components/helper');var Main = (function () {
function Main(name) {
this.name = name;
console.log(this.name);
this.helper = new Helper();
this.helper.sayHello();
}
return Main;
})();window.onload = function () {
var main = new Main('start me up');
};},{"./components/helper":undefined}]},{},[1,2]);
main.ts:
/// import Helper = require('./components/helper');
class Main {name;
helper;constructor(name: string) {
this.name = name;
console.log(this.name)this.helper = new Helper(); this.helper.sayHello();
}
}
window.onload = () => {
var main = new Main('start me up');
}components/helper.ts:
class Helper {
constructor() {}
sayHello() {
console.log('hello from the helper!')
}}
export = Helper;I am using gulp as my task manager trying to use browserify, watchify,
tsify, and browser-sync as my main dev workflow.Gulpfile:
'use strict';
var browserify = require('browserify');var watchify = require('watchify');var tsify = require('tsify');var gulp = require('gulp');var source = require('vinyl-source-stream');var buffer = require('vinyl-buffer');var jasmine = require('gulp-jasmine');var livereload = require('gulp-livereload');var browserSync = require('browser-sync');var reload = browserSync.reload;
/*** Run jasmine tests_/
gulp.task('test', function() {
return gulp.src('test/_.spec.js')
.pipe(jasmine());
});gulp.task('browserSync', function() {
browserSync({
server: {
baseDir: './',
index: 'index.html'
},
open: true,
files: ['dist/bundle.js']
});
});
/** * Transpile TypeScript and bundle */
gulp.task('bundle-ts', function() {var bundler = browserify();
bundler = watchify(bundler);
bundler.on('update', function() {
rebundle();
});bundler.add([
'./src/components/helper.ts',
'./src/main.ts'
])
.plugin('tsify', {target: 'ES5', module: 'amd'});rebundle();
function rebundle() {
return bundler.bundle()
.pipe(source('./dist/bundle.js'))
.pipe(buffer())
.pipe(gulp.dest('.'));
}});
gulp.task('default', function() {
gulp.start(['bundle-ts', 'browserSync']);
});—
Reply to this email directly or view it on GitHub
#35.
from tsify.
OMG! I feel like such an idiot :) Indeed it was the extra include that was causing this.
Thank you!
from tsify.
Awesome, glad to help :)
from tsify.
Related Issues (20)
- Error FileReader on Ionic 3 HOT 1
- Compile errors when using from Docker. HOT 1
- Dont wrap bundle inside anonymous function HOT 4
- Cannot find module with @types import HOT 6
- Any plan to support --incremental flag? HOT 11
- Module aliasing not supported HOT 2
- Cannot find ambient module declaration in .d.ts HOT 7
- importing css causes problems HOT 2
- how to select which files to compile? HOT 2
- TSify is a brilliant tool, thank you guys
- Compiler Opions Error - updating to 4.0.2 from 4.0.1 HOT 7
- Importing nodejs types pollutes global types HOT 2
- tsconfig-files with `composite` set to true fail to build HOT 6
- TypeScript types are likely incorrect HOT 4
- The "path" argument must be of type string. Received undefined HOT 1
- Tsify generates own import types (type_1 instead of type) and uses these types in ts transformed code
- Can't install on npm 7
- Using filesystems with mixed case sensitivity breaks build
- Can't parse ES2020 or higher HOT 1
- Failing to parse expression with null coalescing HOT 1
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 tsify.