diff --git a/packages/server/__fixtures__/stats.json b/packages/server/__fixtures__/stats.json index 0162327e..200c89ce 100644 --- a/packages/server/__fixtures__/stats.json +++ b/packages/server/__fixtures__/stats.json @@ -13,6 +13,10 @@ "letters-B": "letters-B.js", "letters-C": "letters-C.js", "letters-D": "letters-D.js", + "letters-E": [ + "letters-E.css?param", + "letters-E.js?param" + ], "main": [ "main.css", "main.js" @@ -69,6 +73,26 @@ "letters-D" ] }, + { + "name": "letters-E.css?param", + "size": 517, + "chunks": [ + "letters-E" + ], + "chunkNames": [ + "letters-E" + ] + }, + { + "name": "letters-E.js?param", + "size": 517, + "chunks": [ + "letters-E" + ], + "chunkNames": [ + "letters-E" + ] + }, { "name": "main.css", "size": 16, @@ -219,6 +243,17 @@ "children": {}, "childAssets": {} }, + "letters-E": { + "chunks": [ + "letters-E" + ], + "assets": [ + "letters-E.css?param", + "letters-E.js?param" + ], + "children": {}, + "childAssets": {} + }, "moment": { "chunks": [], "assets": [], @@ -298,4 +333,4 @@ "name": "mini-css-extract-plugin node_modules/css-loader/index.js!src/client/main.css" } ] -} \ No newline at end of file +} diff --git a/packages/server/src/ChunkExtractor.js b/packages/server/src/ChunkExtractor.js index 275c9217..fdd7960e 100644 --- a/packages/server/src/ChunkExtractor.js +++ b/packages/server/src/ChunkExtractor.js @@ -170,7 +170,7 @@ class ChunkExtractor { createChunkAsset({ filename, chunk, type, linkType }) { return { filename, - scriptType: extensionToScriptType(path.extname(filename).toLowerCase()), + scriptType: extensionToScriptType(path.extname(filename).split('?')[0].toLowerCase()), chunk, url: this.resolvePublicUrl(filename), path: path.join(this.outputPath, filename), diff --git a/packages/server/src/ChunkExtractor.test.js b/packages/server/src/ChunkExtractor.test.js index 9a0fdc67..dbc4a765 100644 --- a/packages/server/src/ChunkExtractor.test.js +++ b/packages/server/src/ChunkExtractor.test.js @@ -57,6 +57,15 @@ describe('ChunkExtrator', () => { `) }) + it('should allow for query params in chunk names', () => { + extractor.addChunk('letters-E') + expect(extractor.getScriptTags()).toMatchInlineSnapshot(` +" + +" +`) + }) + it('should add extra props if specified', () => { extractor.addChunk('letters-A') expect(extractor.getScriptTags({ nonce: 'testnonce' })) @@ -113,6 +122,31 @@ Array [ `) }) + it('should allow for query params in chunk names', () => { + extractor.addChunk('letters-E') + expect(extractor.getScriptElements()).toMatchInlineSnapshot(` +Array [ +