Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Handling JS filenames with periods #271

Merged
merged 1 commit into from
Sep 12, 2017
Merged
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
2 changes: 1 addition & 1 deletion plugin/save-metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const hostUtils = require('../../utils/host-utils');
module.exports = function SaveMetadata() {

function getFallbackName(name) {
return util.format('SKY_PAGES_READY_%s', name.toUpperCase());
return util.format('SKY_PAGES_READY_%s', name.toUpperCase().replace(/\./g, '_'));
}

this.plugin('emit', (compilation, done) => {
Expand Down
10 changes: 5 additions & 5 deletions test/config-webpack-build-aot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('config webpack build-aot', () => {
expect(json[2].name).toEqual('test2.js');
});

it('should add the SKY_PAGES_READY_X variable to each entry', () => {
it('should add the SKY_PAGES_READY_X variable to each entry, replacing periods', () => {
const lib = require('../config/webpack/build-aot.webpack.config');
const config = lib.getWebpackConfig({
runtime: runtimeUtils.getDefaultRuntime(),
Expand All @@ -166,7 +166,7 @@ describe('config webpack build-aot', () => {
switch (evt) {
case 'emit':
let assets = {
'test.js': {
'a.b.c.js': {
source: () => '// My Source'
}
};
Expand All @@ -176,15 +176,15 @@ describe('config webpack build-aot', () => {
getStats: () => ({
toJson: () => ({
chunks: [
{ id: 1, entry: true, names: ['test'], files: ['test.js'] }
{ id: 1, entry: true, names: ['a.b.c'], files: ['a.b.c.js'] }
]
})
})
}, () => {});

const source = assets['test.js'].source();
const source = assets['a.b.c.js'].source();
expect(source).toContain('// My Source');
expect(source).toContain('var SKY_PAGES_READY_TEST = true;');
expect(source).toContain('var SKY_PAGES_READY_A_B_C = true;');
break;
}
}
Expand Down