diff --git a/packages/core/integration-tests/test/integration/svg-multiple/circle.svg b/packages/core/integration-tests/test/integration/svg-multiple/circle.svg new file mode 100644 index 00000000000..312b4137553 --- /dev/null +++ b/packages/core/integration-tests/test/integration/svg-multiple/circle.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/core/integration-tests/test/integration/svg-multiple/index.js b/packages/core/integration-tests/test/integration/svg-multiple/index.js new file mode 100644 index 00000000000..da16cc9827c --- /dev/null +++ b/packages/core/integration-tests/test/integration/svg-multiple/index.js @@ -0,0 +1,2 @@ +import "./circle.svg"; +import "./square.svg"; diff --git a/packages/core/integration-tests/test/integration/svg-multiple/square.svg b/packages/core/integration-tests/test/integration/svg-multiple/square.svg new file mode 100644 index 00000000000..1fbcd5a72d0 --- /dev/null +++ b/packages/core/integration-tests/test/integration/svg-multiple/square.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/core/integration-tests/test/svg.js b/packages/core/integration-tests/test/svg.js index 1207e6256a7..308e88c4995 100644 --- a/packages/core/integration-tests/test/svg.js +++ b/packages/core/integration-tests/test/svg.js @@ -191,4 +191,22 @@ describe('svg', function() { assert(svg.includes('')); }); + + it('should be in separate bundles', async function() { + const b = await bundle( + path.join(__dirname, '/integration/svg-multiple/index.js'), + ); + + assertBundles(b, [ + { + assets: ['index.js', 'bundle-url.js'], + }, + { + assets: ['circle.svg'], + }, + { + assets: ['square.svg'], + }, + ]); + }); }); diff --git a/packages/transformers/svg-react/src/SvgReactTransformer.js b/packages/transformers/svg-react/src/SvgReactTransformer.js index ceb4a8680a7..bab1c950387 100644 --- a/packages/transformers/svg-react/src/SvgReactTransformer.js +++ b/packages/transformers/svg-react/src/SvgReactTransformer.js @@ -34,6 +34,7 @@ export default (new Transformer({ ); asset.type = 'jsx'; + asset.bundleBehavior = null; asset.setCode(jsx); return [asset]; diff --git a/packages/transformers/svg/src/SVGTransformer.js b/packages/transformers/svg/src/SVGTransformer.js index b6d3be9a8d5..21667f797de 100644 --- a/packages/transformers/svg/src/SVGTransformer.js +++ b/packages/transformers/svg/src/SVGTransformer.js @@ -32,6 +32,8 @@ export default (new Transformer({ }, async transform({asset}) { + asset.bundleBehavior = 'isolated'; + const ast = nullthrows(await asset.getAST()); collectDependencies(asset, ast);