Skip to content

Commit

Permalink
feat: consistent flatModuleFile naming for bundles (#361)
Browse files Browse the repository at this point in the history
Albeit this is not 100% conformant to the file naming suggested in the Angular Package Format spec, it makes the flattened JavaScript bundles more identifiable as they include the all information bits of the module ID.
  • Loading branch information
dherges authored Dec 6, 2017
1 parent 05d09c2 commit 17b4e0f
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 156 deletions.
23 changes: 0 additions & 23 deletions integration/samples/core/specs/bundle.ts

This file was deleted.

4 changes: 2 additions & 2 deletions integration/samples/core/specs/es5-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as path from 'path';

describe(`@sample/core`, () => {

describe(`esm5/core.js`, () => {
describe(`esm5/sample-core.js`, () => {
let API;
before(() => {
API = require('../dist/esm5/core.js');
API = require('../dist/esm5/sample-core.js');
})

it(`should exist`, () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/samples/core/specs/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe(`@sample/core`, () => {
describe(`core.metadata.json`, () => {
let METADATA;
before(() => {
METADATA = require('../dist/core.metadata.json');
METADATA = require('../dist/sample-core.metadata.json');
});

it(`should exist`, () => {
Expand Down
13 changes: 5 additions & 8 deletions integration/samples/core/specs/package.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { expect } from 'chai';
import * as fs from 'fs';
import * as path from 'path';
const BASE = path.resolve(__dirname, '..', 'dist');

describe(`@sample/core`, () => {

describe(`package.json`, () => {
let PACKAGE;
before(() => {
PACKAGE = JSON.parse(fs.readFileSync(`${BASE}/package.json`, 'utf-8'));
PACKAGE = require('../dist/package.json');
});

it(`should exist`, () => {
Expand All @@ -20,19 +17,19 @@ describe(`@sample/core`, () => {
});

it(`should reference "main" bundle (UMD)`, () => {
expect(PACKAGE['main']).to.equal('bundles/core.umd.js');
expect(PACKAGE['main']).to.equal('bundles/sample-core.umd.js');
});

it(`should reference "module" bundle (FESM5, also FESM2014)`, () => {
expect(PACKAGE['module']).to.equal('esm5/core.js');
expect(PACKAGE['module']).to.equal('esm5/sample-core.js');
});

it(`should reference "es2015" bundle (FESM2015)`, () => {
expect(PACKAGE['es2015']).to.equal('esm2015/core.js');
expect(PACKAGE['es2015']).to.equal('esm2015/sample-core.js');
});

it(`should reference "typings" files`, () => {
expect(PACKAGE['typings']).to.equal('core.d.ts');
expect(PACKAGE['typings']).to.equal('sample-core.d.ts');
});

});
Expand Down
6 changes: 3 additions & 3 deletions integration/samples/core/specs/sourcemaps.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'chai';
import * as fs from 'fs';
import * as fs from 'fs-extra';
import * as path from 'path';

describe(`@sample/core`, () => {

describe(`esm5/core.js.map`, () => {
describe(`esm5/sample-core.js.map`, () => {
let sourceMap;
before(() => {
sourceMap = JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'dist', 'esm5', 'core.js.map'), 'utf-8'));
sourceMap = fs.readJsonSync(path.resolve(__dirname, '../dist/esm5/sample-core.js.map'));
})

it(`should exist`, () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/samples/core/specs/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(`@sample/core`, () => {
let TYPINGS;
before(() => {
TYPINGS = fs.readFileSync(
path.resolve(__dirname, '..', 'dist', 'core.d.ts'), 'utf-8');
path.resolve(__dirname, '..', 'dist', 'sample-core.d.ts'), 'utf-8');
});

it(`should exist`, () => {
Expand Down
20 changes: 18 additions & 2 deletions integration/samples/core/specs/umd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,26 @@ import * as path from 'path';

describe(`@sample/core`, () => {

describe(`core.umd.min.js`, () => {
describe(`sample-core.umd.js`, () => {
let BUNDLE;
before(() => {
BUNDLE = fs.readFileSync(
path.resolve(__dirname, '..', 'dist', 'bundles', 'sample-core.umd.js'), 'utf-8');
});

it(`should exist`, () => {
expect(BUNDLE).to.be.ok;
});

it(`should export the module with module name 'sample.core'`, () => {
expect(BUNDLE).to.contain(`global.sample.core = {}`);
});
});

describe(`sample-core.umd.min.js`, () => {
let API;
before(() => {
API = require('../dist/bundles/core.umd.min.js');
API = require('../dist/bundles/sample-core.umd.min.js');
});

it(`should exist`, () => {
Expand Down
5 changes: 1 addition & 4 deletions integration/samples/custom/specs/package.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { expect } from 'chai';
import * as fs from 'fs';
import * as path from 'path';
const BASE = path.resolve(__dirname, '..', 'dist');

describe(`sample-custom`, () => {

describe(`package.json`, () => {
let PACKAGE;
before(() => {
PACKAGE = JSON.parse(fs.readFileSync(`${BASE}/package.json`, 'utf-8'));
PACKAGE = require('../dist/package.json');
});

it(`should exist`, () => {
Expand Down
13 changes: 8 additions & 5 deletions integration/samples/externals/specs/rxjs-lettables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import { Observable } from 'rxjs/Observable';
describe(`@sample/externals`, () => {

describe(`UMD Bundle`, () => {
const api = require('../dist/bundles/externals.umd.min.js');
let API;
before(() => {
API = require('../dist/bundles/sample-externals.umd.min.js');
});

it(`should export 'target$'`, () => {
expect(api.target$).to.be.instanceof(Observable);
expect(API.target$).to.be.instanceof(Observable);
});

it(`'target$' should be .subscribe()-able and emit values`, () => {
const values: number[] = [];
const subscription = api.target$.subscribe(
const subscription = API.target$.subscribe(
(next) => values.push(next),
(err) => {},
() => {}
Expand All @@ -25,11 +28,11 @@ describe(`@sample/externals`, () => {
});

it(`should export 'SomeModule'`, () => {
expect(api.SomeModule).to.be.ok;
expect(API.SomeModule).to.be.ok;
});

it(`should export RxJsOperators`, () => {
expect(api.RxJsOperators).to.be.ok;
expect(API.RxJsOperators).to.be.ok;
});
});

Expand Down
2 changes: 1 addition & 1 deletion integration/samples/jsx/specs/react-jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe(`@sample/jsx`, () => {
describe(`jsx.es5.js`, () => {
let API;
before(() => {
API = require('../dist/esm5/jsx.js');
API = require('../dist/esm5/sample-jsx.js');
});

it(`should exist`, () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/samples/material/specs/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe(`@sample/material`, () => {
describe(`material.umd.js`, () => {
let UMD_MODULE;
before(() => {
UMD_MODULE = require('../dist/bundles/material.umd.js');
UMD_MODULE = require('../dist/bundles/sample-material.umd.js');
});

it(`should exist`, () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/samples/material/specs/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe(`@sample/material`, () => {
describe(`material.metadata.json`, () => {
let METADATA;
before(() => {
METADATA = require('../dist/material.metadata.json');
METADATA = require('../dist/sample-material.metadata.json');
});

it(`should exist`, () => {
Expand Down
13 changes: 5 additions & 8 deletions integration/samples/material/specs/package.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { expect } from 'chai';
import * as fs from 'fs';
import * as path from 'path';
const BASE = path.resolve(__dirname, '..', 'dist');

describe(`@sample/material`, () => {

describe(`package.json`, () => {
let PACKAGE;
before(() => {
PACKAGE = JSON.parse(fs.readFileSync(`${BASE}/package.json`, 'utf-8'));
PACKAGE = require('../dist/package.json');
});

it(`should exist`, () => {
Expand All @@ -20,19 +17,19 @@ describe(`@sample/material`, () => {
});

it(`should reference "main" bundle (UMD)`, () => {
expect(PACKAGE['main']).to.equal('bundles/material.umd.js');
expect(PACKAGE['main']).to.equal('bundles/sample-material.umd.js');
});

it(`should reference "module" bundle (FESM5, also FESM2014)`, () => {
expect(PACKAGE['module']).to.equal('esm5/material.js');
expect(PACKAGE['module']).to.equal('esm5/sample-material.js');
});

it(`should reference "es2015" bundle (FESM2015)`, () => {
expect(PACKAGE['es2015']).to.equal('esm2015/material.js');
expect(PACKAGE['es2015']).to.equal('esm2015/sample-material.js');
});

it(`should reference "typings" files`, () => {
expect(PACKAGE['typings']).to.equal('material.d.ts');
expect(PACKAGE['typings']).to.equal('sample-material.d.ts');
});
});
});
2 changes: 1 addition & 1 deletion integration/samples/material/specs/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(`@sample/material`, () => {
let TYPINGS;
before(() => {
TYPINGS = fs.readFileSync(
path.resolve(__dirname, '..', 'dist', 'material.d.ts'), 'utf-8');
path.resolve(__dirname, '..', 'dist', 'sample-material.d.ts'), 'utf-8');
});

it(`should exist`, () => {
Expand Down
4 changes: 2 additions & 2 deletions integration/samples/same-name/specs/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe(`@sample/same-name`, () => {
let BUNDLE;
before(() => {
BUNDLE = fs.readFileSync(
path.resolve(__dirname, '..', 'dist', 'bundles', 'testing.umd.js'), 'utf-8');
path.resolve(__dirname, '..', 'dist', 'bundles', 'sample-testing.umd.js'), 'utf-8');
});

it(`should exist`, () => {
Expand All @@ -25,7 +25,7 @@ describe(`@sample/same-name`, () => {
let BUNDLE;
before(() => {
BUNDLE = fs.readFileSync(
path.resolve(__dirname, '..', 'dist', 'bundles', 'testing-testing.umd.js'), 'utf-8');
path.resolve(__dirname, '..', 'dist', 'bundles', 'sample-testing-testing.umd.js'), 'utf-8');
});

it(`should exist`, () => {
Expand Down
8 changes: 4 additions & 4 deletions integration/samples/same-name/specs/es5-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as path from 'path';

describe(`@sample/same-name`, () => {

describe(`esm5/testing.js`, () => {
describe(`esm5/sample-testing.js`, () => {
let API;
before(() => {
API = require('../dist/esm5/testing.js');
API = require('../dist/esm5/sample-testing.js');
})

it(`should exist`, () => {
Expand All @@ -20,10 +20,10 @@ describe(`@sample/same-name`, () => {

});

describe(`esm5/testing/testing.js`, () => {
describe(`esm5/sample-testing-testing.js`, () => {
let APITesting;
before(() => {
APITesting = require('../dist/esm5/testing/testing.js');
APITesting = require('../dist/esm5/sample-testing-testing.js');
});

it(`should exist`, () => {
Expand Down
8 changes: 4 additions & 4 deletions integration/samples/same-name/specs/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import * as path from 'path';

describe(`@sample/same-name`, () => {

describe(`testing.metadata.json`, () => {
describe(`sample-testing.metadata.json`, () => {
let METADATA;
before(() => {
METADATA = require('../dist/testing.metadata.json');
METADATA = require('../dist/sample-testing.metadata.json');
});

it(`should exist`, () => {
Expand All @@ -32,10 +32,10 @@ describe(`@sample/same-name`, () => {

});

describe(`testing/testing.metadata.json`, () => {
describe(`testing/sample-testing-testing.metadata.json`, () => {
let METADATA;
before(() => {
METADATA = require('../dist/testing/testing.metadata.json');
METADATA = require('../dist/testing/sample-testing-testing.metadata.json');
});

it(`should exist`, () => {
Expand Down
Loading

0 comments on commit 17b4e0f

Please sign in to comment.