diff --git a/flow-libs/postcss.js.flow b/flow-libs/postcss.js.flow index 705bd5df272..065edf416b5 100644 --- a/flow-libs/postcss.js.flow +++ b/flow-libs/postcss.js.flow @@ -4,7 +4,8 @@ // Derived from the PostCSS docs available at // http://api.postcss.org/postcss.html. -import type {SourceMapGenerator} from 'source-map'; +// eslint-disable-next-line import/no-extraneous-dependencies +import typeof {SourceMapGenerator} from 'source-map'; declare module 'postcss' { declare type NodeCallback = (Node, number) => false | void; @@ -23,20 +24,23 @@ declare module 'postcss' { declare interface Root extends Container {} declare class Processor { - process(css: string | Result, opts?: processOptions): Promise; + process( + css: string | Result | Root, + opts?: ProcessOptions, + ): Promise; } - declare type ProcessOptions = {| - from?: string, - to?: string, - map?: MapOptions, - parser?: parser, - stringifier?: stringifier, - syntax?: {| + declare type ProcessOptions = $Shape<{| + from: string, + to: string, + map: MapOptions, + parser: parser, + stringifier: stringifier, + syntax: {| parser: parser, stringifier: stringifier, |}, - |}; + |}>; declare type MapOptions = {| inline?: boolean, diff --git a/packages/core/cache/src/Cache.js b/packages/core/cache/src/Cache.js index 922d5e01e92..e5b85a0bec9 100644 --- a/packages/core/cache/src/Cache.js +++ b/packages/core/cache/src/Cache.js @@ -8,7 +8,7 @@ import type {FileSystem} from '@parcel/fs'; import path from 'path'; import logger from '@parcel/logger'; import {serialize, deserialize, registerSerializableClass} from '@parcel/core'; -// $FlowFixMe this is untyped +// flowlint-next-line untyped-import:off import packageJson from '../package.json'; export default class Cache { diff --git a/packages/core/core/src/utils.js b/packages/core/core/src/utils.js index 8a21633bb89..b55c9654120 100644 --- a/packages/core/core/src/utils.js +++ b/packages/core/core/src/utils.js @@ -10,7 +10,7 @@ import Graph from './Graph'; import ParcelConfig from './ParcelConfig'; import {RequestGraph} from './RequestTracker'; import Config from './public/Config'; -// $FlowFixMe this is untyped +// flowlint-next-line untyped-import:off import packageJson from '../package.json'; export function getBundleGroupId(bundleGroup: BundleGroup): string { diff --git a/packages/core/integration-tests/test/css.js b/packages/core/integration-tests/test/css.js index c42859a98a4..b11ca128e15 100644 --- a/packages/core/integration-tests/test/css.js +++ b/packages/core/integration-tests/test/css.js @@ -264,6 +264,7 @@ describe('css', () => { path.join(__dirname, '/integration/cssnano/index.js'), { minify: true, + sourceMaps: false, }, ); @@ -275,19 +276,43 @@ describe('css', () => { assert(css.includes('.local')); assert(css.includes('.index')); - // TODO: Make this `2` when a `sourceMappingURL` is added assert.equal(css.split('\n').length, 1); }); + it('should produce a sourcemap when sourceMaps are used', async function() { + await bundle(path.join(__dirname, '/integration/cssnano/index.js'), { + minify: true, + }); + + let css = await outputFS.readFile(path.join(distDir, 'index.css'), 'utf8'); + assert(css.includes('.local')); + assert(css.includes('.index')); + + let lines = css.trim().split('\n'); + assert.equal(lines.length, 2); + assert.equal(lines[1], '/*# sourceMappingURL=index.css.map */'); + + let map = JSON.parse( + await outputFS.readFile(path.join(distDir, 'index.css.map'), 'utf8'), + ); + assert.equal(map.file, 'index.css.map'); + assert.equal(map.mappings, 'AAAA,OACA,WACA,CCFA,OACA,SACA'); + assert.deepEqual(map.sources, [ + 'integration/cssnano/local.css', + 'integration/cssnano/index.css', + ]); + }); + it('should inline data-urls for text-encoded files', async () => { - await bundle(path.join(__dirname, '/integration/data-url/text.css')); + await bundle(path.join(__dirname, '/integration/data-url/text.css'), { + sourceMaps: false, + }); let css = await outputFS.readFile(path.join(distDir, 'text.css'), 'utf8'); assert.equal( - css, + css.trim(), `.svg-img { background-image: url('data:image/svg+xml,%3Csvg%3E%0A%0A%3C%2Fsvg%3E%0A'); -} -`, +}`, ); }); diff --git a/packages/core/integration-tests/test/html.js b/packages/core/integration-tests/test/html.js index 5ec98f3b388..24389970b1b 100644 --- a/packages/core/integration-tests/test/html.js +++ b/packages/core/integration-tests/test/html.js @@ -329,8 +329,8 @@ describe('html', function() { // mergeStyles assert( - html.includes( - '', + html.match( + /')); + assert( + html.match( + /