Skip to content

Commit

Permalink
tsc build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lynchbomb committed Jul 16, 2018
1 parent 012591a commit 92ea3ee
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 152 deletions.
67 changes: 30 additions & 37 deletions Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,46 @@ Unless required by applicable law or agreed to in writing, software
distribute

const Funnel = require('broccoli-funnel');
const uglify = require('broccoli-uglify-sourcemap');
const typescript = require('broccoli-typescript-compiler').default;
const typescript = require('broccoli-typescript-compiler').typescript;
const Rollup = require('broccoli-rollup');
const Merge = require('broccoli-merge-trees');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const buble = require('rollup-plugin-buble');
const replace = require('broccoli-string-replace');

const es6Tree = typescript('src');

const es6 = new Rollup(es6Tree, {
annotation: 'es6',
rollup: {
input: 'index.js',
external: ['spaniel'],
output: [{
file: 'es6/spaniel.js',
format: 'es'
}],
plugins: [resolve({
module: true,
customResolveOptions: {
moduleDirectory: 'node_modules'
}
})],
onwarn: (o) => onRollupWarn(o)
const es6Tree = typescript('src', {
tsconfig: {
compilerOptions: {
"noImplicitAny": true,
"declaration": true,
"isolatedModules": false,
"module": "es2015",
"target": "es5",
"outDir": "es6",
"sourceMap": true,
"moduleResolution": "node"
},
filesGlob: [
"**/*.ts"
]
}
});

const umdTree = new Rollup(es6Tree, {
annotation: 'umd',
const umdTree = replace(new Rollup(es6Tree, {
rollup: {
input: 'index.js',
external: ['spaniel'],
output: [{
input: 'es6/index.js',
output: {
file: 'spaniel.js',
exports: 'named',
format: 'umd',
name: 'spaniel',
exports: 'named',
sourcemap: true
}],
plugins: [buble(), commonjs(), resolve({
main: true,
customResolveOptions: {
moduleDirectory: 'node_modules'
}
})],
onwarn: (o) => onRollupWarn(o)
},
onwarn: (opt) => onRollupWarn(opt)
}
}), {
files: [ 'spaniel.js' ],
pattern: {
match: /undefined.__extends/g,
replacement: 'false'
}
});

Expand All @@ -63,7 +56,7 @@ const minTree = uglify(new Funnel(umdTree, {
compress: true
});

module.exports = new Merge([es6, umdTree, minTree]);
module.exports = new Merge([es6Tree, umdTree, minTree]);

function onRollupWarn({ code, loc, frame, message }) {
// ahead-of-time (AOT) compiler warning suppression
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"description": "LinkedIn's viewport tracking library",
"license": "Apache 2.0",
"main": "exports/spaniel.js",
"module": "exports/es6/spaniel.js",
"jsnext:main": "exports/es6/index.js",
"module": "exports/es6/index.js",
"typings": "exports/es6/index.d.ts",
"scripts": {
"test": "npm run build && testem ci && node test/headless/run",
"test": "tsc && npm run build && testem ci && node test/headless/run",
"test:headless": "mocha --require babel-core/register test/headless/specs/**/*.js",
"serve": "npm run build && node test/headless/server/app",
"watch": "broccoli-timepiece exports",
Expand Down Expand Up @@ -49,22 +51,20 @@
"broccoli-funnel": "^2.0.1",
"broccoli-merge-trees": "^3.0.0",
"broccoli-rollup": "^2.1.1",
"broccoli-typescript-compiler": "^3.0.1",
"broccoli-typescript-compiler": "^1.0.1",
"broccoli-uglify-sourcemap": "^2.2.0",
"chai": "^4.1.2",
"express": "^4.16.3",
"gzip-size": "^5.0.0",
"mocha": "^5.2.0",
"nightmare": "^3.0.1",
"pretty-bytes": "^5.1.0",
"rollup-plugin-buble": "^0.19.2",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"rsvp": "^4.8.2",
"rsvp": "^4.8.3",
"serve-static": "^1.13.2",
"sinon": "^6.1.2",
"sinon": "^6.1.3",
"testem": "^2.8.2",
"tslint": "^5.10.0",
"typescript": "2.9.2"
"typescript": "2.9.2",
"broccoli-string-replace": "^0.1.2"
}
}
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
} from './spaniel-observer';

import {
getGlobalEngine
getGlobalEngine,
setGlobalEngine
} from './metal/engine';

import {
Expand All @@ -56,6 +57,7 @@ export {
SpanielObserver,
SpanielTrackedElement,
getGlobalEngine,
setGlobalEngine,
w as __w__,
invalidate
};
Expand Down
8 changes: 8 additions & 0 deletions src/metal/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export class Engine implements EngineInterface {

let globalEngine: EngineInterface = null;

export function setGlobalEngine(engine: EngineInterface): boolean {
if (!!globalEngine) {
return false;
}
globalEngine = engine;
return true;
}

export function getGlobalEngine() {
return globalEngine || (globalEngine = new Engine());
}
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"declaration": true,
"isolatedModules": false,
"module": "es2015",
"target": "es6",
"target": "es5",
"sourceMap": true,
"moduleResolution": "node",
"noUnusedLocals": true
"noUnusedLocals": true,
"outDir": "exports/es6"
},
"filesGlob": [
"**/*.ts"
Expand Down
Loading

0 comments on commit 92ea3ee

Please sign in to comment.