Skip to content

Commit

Permalink
Fix inline HTML bundles (#6486)
Browse files Browse the repository at this point in the history
  • Loading branch information
devongovett committed Jun 20, 2021
1 parent 5504627 commit cf17201
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/configs/default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"bundler": "@parcel/bundler-default",
"transformers": {
"types:*.{ts,tsx}": ["@parcel/transformer-typescript-types"],
"bundle-text:*": ["@parcel/transformer-inline-string", "..."],
"data-url:*": ["@parcel/transformer-inline-string", "..."],
"bundle-text:*": ["...", "@parcel/transformer-inline-string"],
"data-url:*": ["...", "@parcel/transformer-inline-string"],
"*.{js,mjs,jsm,jsx,es6,cjs,ts,tsx}": [
"@parcel/transformer-babel",
"@parcel/transformer-js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<script type="module" src="./main.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import otherHTML from "bundle-text:./other.html"
export default otherHTML;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>test</p>
9 changes: 9 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,15 @@ describe('javascript', function() {
assert(!cssBundleContent.includes('sourceMappingURL'));
});

it("should inline an HTML bundle's compiled text with `bundle-text`", async () => {
let b = await bundle(
path.join(__dirname, '/integration/bundle-text/index.html'),
);

let res = await run(b);
assert.equal(res.default, '<p>test</p>\n');
});

it('should inline text content as url-encoded text and mime type with `data-url:*` imports', async () => {
let b = await bundle(path.join(__dirname, '/integration/data-url/text.js'));

Expand Down

0 comments on commit cf17201

Please sign in to comment.