Skip to content

Commit

Permalink
Help improvements and tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
obany committed Jul 19, 2017
1 parent d76be54 commit 87f2e01
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 115 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -0,0 +1,2 @@
dist
test
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -3,4 +3,4 @@ node_modules
*.bat
*.lock
*.log

package-lock.json
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
# v0.4.1
* Help improvements and tidy up

# v0.4.0
* Added buildConfigurations which allows bundling, minification, sourcemaps and build variables
* Removed unused staticClientModules from unite.json
Expand Down
36 changes: 0 additions & 36 deletions README.md
Expand Up @@ -2,39 +2,3 @@
Core of the UniteJS JavaScript framework management tool.

See [UniteJS CLI](https://github.com/unitejs/cli#readme) for usage.





# Quirks
## Tests code using TypeScript and Chai
The RequireJS loader would normally use the following syntax to import Chai as the module has no default export so we just treat the whole module as the class
import * as Chai from "chai";
TypeScript calls the class methods with Chai.should etc

The SystemJS loader would normally use the following syntax to import Chai as it creates a synthetic default export
import Chai from "chai";
TypeScript calls the class methods with chai_1.default.should etc

If we switch on the allowSyntheticDefaultImports option for RequireJS usage the SystemJS syntax code will compile but the generated code will try to access the .default variable which does not exist.

To keep the test code the same for both module loaders the following import syntax is used.
import * as ChaiModule from "chai";
const Chai = (<any>ChaiModule).default || ChaiModule;

The ES6 code always uses the same syntax
import Chai from "chai"

and Babel introduces the following code for RequireJS

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}

So the question is where does the fix go? At the moment I am leaning towards TypeScript which needs to introduce a similar interop to Babel. As well as the allowSyntheticDefaultImports which is a compile options only I think that a generateSyntheticDefaultImports might also be needed.

See https://github.com/Microsoft/TypeScript/issues/16093
and https://github.com/Microsoft/TypeScript/issues/16090
69 changes: 0 additions & 69 deletions TODO.md

This file was deleted.

14 changes: 7 additions & 7 deletions gulpfile.js
Expand Up @@ -5,7 +5,6 @@ const tslint = require("tslint");
const sourcemaps = require('gulp-sourcemaps');
const del = require('del');
const mocha = require('gulp-mocha');
const path = require('path');
const merge = require('merge2');
const runSequence = require('run-sequence');

Expand All @@ -16,9 +15,6 @@ const testFolder = 'test/';
const tsSrcGlob = srcFolder + '**/*.ts';
const cleanTestGlob = testFolder + '/**/*.js';
const tsTestGlob = testFolder + '**/*.spec.ts';
const jsTestGlob = testFolder + '**/*.spec.js';

const tsProject = tsc.createProject(tsConfigFile);

gulp.task('build-clean', (cb) => {
return del(distFolder, cb);
Expand All @@ -35,12 +31,14 @@ gulp.task('build-lint', () => {
});

gulp.task('build-transpile', () => {
const tsProject = tsc.createProject(tsConfigFile);

let errorCount = 0;

var tsResult = gulp.src(tsSrcGlob)
.pipe(sourcemaps.init())
.pipe(tsProject())
.on("error", (err) => {
.on("error", () => {
errorCount++;
})

Expand Down Expand Up @@ -77,6 +75,8 @@ gulp.task('test-lint', () => {
});

gulp.task('test-transpile', () => {
const tsProject = tsc.createProject(tsConfigFile);

var tsResult = gulp.src(tsTestGlob)
.pipe(tsProject());

Expand All @@ -95,4 +95,4 @@ gulp.task('test', (cb) => {
runSequence('test-clean', 'test-transpile', 'test-lint', cb);
});

gulp.task('clean-all', ['clean-build', 'clean-test']);
gulp.task('clean-all', ['build-clean', 'test-clean']);
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "unitejs-core",
"version": "0.4.0",
"version": "0.4.1",
"description": "Core of the UniteJS JavaScript framework management tool.",
"main": "dist/unitejs-core.js",
"types": "dist/unitejs-core.d.ts",
Expand All @@ -10,6 +10,7 @@
},
"keywords": [
"unite",
"unitejs",
"javascript",
"typescript",
"babel",
Expand Down

0 comments on commit 87f2e01

Please sign in to comment.