Skip to content

Commit

Permalink
Remove blob-url from the default config
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Binns-Smith committed Nov 6, 2019
1 parent 933113b commit cc36cee
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 46 deletions.
2 changes: 0 additions & 2 deletions packages/configs/default/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"bundler": "@parcel/bundler-default",
"transforms": {
"types:*.{ts,tsx}": ["@parcel/transformer-typescript-types"],
"blob-url:*": ["@parcel/transformer-inline", "..."],
"data-url:*": ["@parcel/transformer-inline-string", "..."],
"*.{js,mjs,jsm,jsx,es6,ts,tsx}": [
"@parcel/transformer-babel",
Expand Down Expand Up @@ -32,7 +31,6 @@
},
"optimizers": {
"data-url:*": ["...", "@parcel/optimizer-data-url"],
"blob-url:*": ["...", "@parcel/optimizer-blob-url"],
"*.css": ["@parcel/optimizer-cssnano"],
"*.js": ["@parcel/optimizer-terser"],
"*.html": ["@parcel/optimizer-htmlnano"]
Expand Down
2 changes: 0 additions & 2 deletions packages/configs/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"@parcel/bundler-default": "^2.0.0-alpha.2.1",
"@parcel/namer-default": "^2.0.0-alpha.2.1",
"@parcel/optimizer-cssnano": "^2.0.0-alpha.2.1",
"@parcel/optimizer-blob-url": "^2.0.0-alpha.2.1",
"@parcel/optimizer-data-url": "^2.0.0-alpha.2.1",
"@parcel/optimizer-terser": "^2.0.0-alpha.2.1",
"@parcel/optimizer-htmlnano": "^2.0.0-alpha.2.1",
Expand All @@ -36,7 +35,6 @@
"@parcel/transformer-coffeescript": "^2.0.0-alpha.2.1",
"@parcel/transformer-css": "^2.0.0-alpha.2.1",
"@parcel/transformer-html": "^2.0.0-alpha.2.1",
"@parcel/transformer-inline": "^2.0.0-alpha.2.1",
"@parcel/transformer-inline-string": "^2.0.0-alpha.2.1",
"@parcel/transformer-js": "^2.0.0-alpha.2.1",
"@parcel/transformer-json": "^2.0.0-alpha.2.1",
Expand Down
57 changes: 57 additions & 0 deletions packages/core/integration-tests/test/blob-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// @flow strict-local

import assert from 'assert';
import path from 'path';
import {bundle, distDir, outputFS, inputFS} from '@parcel/test-utils';

const configPath = path.join(__dirname, '/integration/blob-url/.parcelrc');

const config = {
...JSON.parse(inputFS.readFileSync(configPath)),
filePath: configPath
};

describe('blob urls', () => {
it('should inline compiled content as a blob url with `blob-url:*` imports', async () => {
await bundle(path.join(__dirname, '/integration/blob-url/index.js'), {
config
});

let bundleContent = await outputFS.readFile(
path.join(distDir, 'index.js'),
'utf8'
);
assert(
bundleContent.includes(
'new Worker(URL.createObjectURL(new Blob(["// modules are defined as an array\\n'
)
);
assert(
bundleContent.includes(
'self.postMessage(\\"this should appear in the bundle\\\\n\\")'
)
);
});

it('should inline minified content as a blob url with `blob-url:*` imports', async () => {
await bundle(path.join(__dirname, '/integration/blob-url/index.js'), {
config,
minify: true
});

let bundleContent = await outputFS.readFile(
path.join(distDir, 'index.js'),
'utf8'
);
assert(
bundleContent.includes(
"new Worker(URL.createObjectURL(new Blob(['!function("
)
);
assert(
bundleContent.includes(
'self.postMessage("this should appear in the bundle\\\\n")'
)
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

{
"extends": "@parcel/config-default",
"transforms": {
"blob-url:*": ["@parcel/transformer-inline", "..."]
},
"optimizers": {
"blob-url:*": ["...", "@parcel/optimizer-blob-url"]
}
}
40 changes: 0 additions & 40 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -1585,46 +1585,6 @@ describe('javascript', function() {
await run(b);
});

it('should inline compiled content as a blob url with `blob-url:*` imports', async () => {
await bundle(path.join(__dirname, '/integration/blob-url/index.js'));

let bundleContent = await outputFS.readFile(
path.join(distDir, 'index.js'),
'utf8'
);
assert(
bundleContent.includes(
'new Worker(URL.createObjectURL(new Blob(["// modules are defined as an array\\n'
)
);
assert(
bundleContent.includes(
'self.postMessage(\\"this should appear in the bundle\\\\n\\")'
)
);
});

it('should inline minified content as a blob url with `blob-url:*` imports', async () => {
await bundle(path.join(__dirname, '/integration/blob-url/index.js'), {
minify: true
});

let bundleContent = await outputFS.readFile(
path.join(distDir, 'index.js'),
'utf8'
);
assert(
bundleContent.includes(
"new Worker(URL.createObjectURL(new Blob(['!function("
)
);
assert(
bundleContent.includes(
'self.postMessage("this should appear in the bundle\\\\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
4 changes: 2 additions & 2 deletions packages/core/test-utils/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ If you don't know how, check here: https://bit.ly/2UmWsbD

export function bundler(
entries: FilePath | Array<FilePath>,
opts: InitialParcelOptions
opts?: InitialParcelOptions
) {
return new Parcel({
entries,
Expand All @@ -118,7 +118,7 @@ export function bundler(

export async function bundle(
entries: FilePath | Array<FilePath>,
opts: InitialParcelOptions
opts?: InitialParcelOptions
): Promise<BundleGraph> {
return nullthrows(await bundler(entries, opts).run());
}
Expand Down

0 comments on commit cc36cee

Please sign in to comment.