Skip to content

Build cleanup and output declarations #343

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 77 additions & 55 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,78 +20,100 @@ module.exports = function (app) {
})
]);

const qunit = new Funnel(path.dirname(require.resolve('qunit')), {
annotation: 'tests/qunit.{js,css}',
destDir: 'tests',
files: ['qunit.css', 'qunit.js']
});

const loader = new Funnel(path.dirname(require.resolve('loader.js')), {
annotation: 'tests/loader.js',
destDir: 'tests',
files: ['loader.js']
});

const tests = new Funnel(__dirname + '/tests', {
destDir: 'tests',
files: ['index.html']
});

const compiled = typescript(src, {
throwOnError: process.env.EMBER_ENV === 'production',
});

const compiledDeclarations = typescript('lib', {
tsconfig: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we shouldn't need to pass tsconfig here, it should just be able to use our top level tsconfig.json.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't explicitly flag for declaration here and default to tsconfig with declaration: true we will have to cherry-pick out the .d.ts files for tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this brings up a good point as to; do we actually need to output tests within dist?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compilerOptions: {
"declaration": true,
}
}
});

const backburner = new Rollup(compiled, {
annotation: 'backburner.js',
rollup: {
input: 'lib/index.js',
output: {
output: [{
file: 'es6/backburner.js',
format: 'es',
sourcemap: true
},
format: 'es',
sourcemap: true,
exports: 'named'
}],
plugins: [
loadWithInlineMap()
]
}
});

const amdNamed = new Rollup(compiled, {
rollup: {
input: 'lib/index.js',
output: [{
file: 'named-amd/backburner.js',
exports: 'named',
format: 'amd',
amd: { id: 'backburner' },
sourcemap: true
}, {
file: 'backburner.js',
format: 'cjs',
sourcemap: true,
exports: 'named'
}],
plugins: [
loadWithInlineMap(),
buble()
]
}
});

const amdTests = new Rollup(compiled, {
annotation: 'named-amd/tests.js',
rollup: {
input: 'tests/index.js',
external: ['backburner'],
output: [{
file: 'named-amd/tests.js',
format: 'amd',
amd: { id: 'backburner-tests' },
sourcemap: true,
exports: 'named'
}],
plugins: [
loadWithInlineMap(),
buble()
]
}
});

return new MergeTrees([
backburner,
new Rollup(compiled, {
rollup: {
input: 'lib/index.js',
plugins: [
loadWithInlineMap(),
buble()
],
output: [{
file: 'named-amd/backburner.js',
exports: 'named',
format: 'amd',
amd: { id: 'backburner' },
sourcemap: true
}, {
file: 'backburner.js',
format: 'cjs',
sourcemap: true
}]
}
}),
new Rollup(compiled, {
annotation: 'named-amd/tests.js',
rollup: {
input: 'tests/index.js',
external: ['backburner'],
plugins: [
loadWithInlineMap(),
buble()
],
output: [{
file: 'named-amd/tests.js',
format: 'amd',
amd: { id: 'backburner-tests' },
sourcemap: true
}]
}
}),
new Funnel(path.dirname(require.resolve('qunit')), {
annotation: 'tests/qunit.{js,css}',
destDir: 'tests',
files: ['qunit.css', 'qunit.js']
}),
new Funnel(path.dirname(require.resolve('loader.js')), {
annotation: 'tests/loader.js',
destDir: 'tests',
files: ['loader.js']
}),
new Funnel(__dirname + '/tests', {
destDir: 'tests',
files: ['index.html']
})
compiledDeclarations,
amdNamed,
amdTests,
qunit,
loader,
tests
], {
annotation: 'dist'
});
Expand Down
3 changes: 2 additions & 1 deletion lib/backburner/deferred-action-queues.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IQueueItem } from './interfaces';
import Queue, { QUEUE_STATE } from './queue';

export default class DeferredActionQueues {
Expand Down Expand Up @@ -25,7 +26,7 @@ export default class DeferredActionQueues {
@param {Any} stack
@return queue
*/
public schedule(queueName: string, target: any, method: any, args: any, onceFlag: boolean, stack: any) {
public schedule(queueName: string, target: any, method: any, args: any, onceFlag: boolean, stack: any): IQueueItem {
let queues = this.queues;
let queue = queues[queueName];

Expand Down
7 changes: 7 additions & 0 deletions lib/backburner/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface IQueueItem {
queue: Object;
target: any;
method: any;
}

export type Timer = string | number;
8 changes: 6 additions & 2 deletions lib/backburner/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import {
getOnError
} from './utils';

import {
IQueueItem
} from './interfaces';

export const enum QUEUE_STATE {
Pause = 1
}
Expand Down Expand Up @@ -134,7 +138,7 @@ export default class Queue {
return false;
}

public push(target, method, args, stack) {
public push(target, method, args, stack): IQueueItem {
this._queue.push(target, method, args, stack);

return {
Expand All @@ -144,7 +148,7 @@ export default class Queue {
};
}

public pushUnique(target, method, args, stack) {
public pushUnique(target, method, args, stack): IQueueItem {
let localQueueMap = this.targetQueues.get(target);

if (localQueueMap === undefined) {
Expand Down
5 changes: 2 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ import searchTimer from './backburner/binary-search';
import DeferredActionQueues from './backburner/deferred-action-queues';
import iteratorDrain, { Iterable } from './backburner/iterator-drain';

import { IQueueItem, Timer } from './backburner/interfaces';
import Queue, { QUEUE_STATE } from './backburner/queue';

type Timer = string | number;

const noop = function() {};

const SET_TIMEOUT = setTimeout;
Expand Down Expand Up @@ -371,7 +370,7 @@ export default class Backburner {
@param {Iterable} an iterable of functions to execute
@return method result
*/
public scheduleIterable(queueName: string, iterable: () => Iterable) {
public scheduleIterable(queueName: string, iterable: () => Iterable): IQueueItem {
scheduleIterableCount++;
let stack = this.DEBUG ? new Error() : undefined;
return this._ensureInstance().schedule(queueName, null, iteratorDrain, [iterable], false, stack);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"author": "Erik Bryn",
"main": "dist/backburner.js",
"jsnext:main": "dist/backburner.js",
"typings": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/BackburnerJS/backburner.js.git"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"lib/index.ts",
"tests/index.ts"
]
}
}