feat(bazel): prefix private-export (barred-latin-o) symbols (#23007)

This allows a bundle index to be re-exported by a higher-level module without fear of collisions.
Under bazel, we always set the prefix to be underscore-joined workspace, package, label

PR Close #23007
This commit is contained in:
Alex Eagle
2018-03-26 14:34:44 -07:00
committed by Matias Niemelä
parent 7a406a32fa
commit 27e14b2fb3
6 changed files with 24 additions and 14 deletions

View File

@ -19,10 +19,10 @@ describe('metadata bundler', () => {
it('should be able to bundle a simple library', () => {
const host = new MockStringBundlerHost('/', SIMPLE_LIBRARY);
const bundler = new MetadataBundler('/lib/index', undefined, host);
const bundler = new MetadataBundler('/lib/index', undefined, host, 'prfx_');
const result = bundler.getMetadataBundle();
expect(Object.keys(result.metadata.metadata).sort()).toEqual([
'ONE_CLASSES', 'One', 'OneMore', 'TWO_CLASSES', 'Two', 'TwoMore', 'ɵa', 'ɵb'
'ONE_CLASSES', 'One', 'OneMore', 'TWO_CLASSES', 'Two', 'TwoMore', prfx_a', prfx_b'
]);
const originalOne = './src/one';
@ -34,11 +34,11 @@ describe('metadata bundler', () => {
{name: 'ONE_CLASSES', value: originalOne}, {name: 'One', value: originalOne},
{name: 'OneMore', value: originalOne}, {name: 'TWO_CLASSES', value: originalTwo},
{name: 'Two', value: originalTwo}, {name: 'TwoMore', value: originalTwo},
{name: 'ɵa', value: originalOne}, {name: 'ɵb', value: originalTwo}
{name: prfx_a', value: originalOne}, {name: prfx_b', value: originalTwo}
]);
expect(result.privates).toEqual([
{privateName: 'ɵa', name: 'PrivateOne', module: originalOne},
{privateName: 'ɵb', name: 'PrivateTwo', module: originalTwo}
{privateName: prfx_a', name: 'PrivateOne', module: originalOne},
{privateName: prfx_b', name: 'PrivateTwo', module: originalTwo}
]);
});