Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

refactor: apply webpack-defaults #25

Closed
wants to merge 2 commits into from
Closed

Conversation

joshwiens
Copy link
Member

@joshwiens joshwiens commented Apr 9, 2017

Intended to be merged & released as a part of 1.0.0 on a beta dist-tag once this has been finished and properly tested.

BREAKING CHANGE:

Enforces NodeJS > 4.8 via engines

Closes #25

@joshwiens joshwiens self-assigned this Apr 9, 2017
@joshwiens joshwiens removed their assignment Aug 17, 2017
@michael-ciniawsky michael-ciniawsky changed the title refactor: apply webpack defaults refactor: apply webpack-defaults Sep 27, 2017
@michael-ciniawsky michael-ciniawsky added this to the 1.0.0 milestone Sep 27, 2017
@codecov
Copy link

codecov bot commented Oct 1, 2017

Codecov Report

❗ No coverage uploaded for pull request base (master@215fba7). Click here to learn what that means.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #25   +/-   ##
=========================================
  Coverage          ?   66.66%           
=========================================
  Files             ?        2           
  Lines             ?        3           
  Branches          ?        0           
=========================================
  Hits              ?        2           
  Misses            ?        1           
  Partials          ?        0
Impacted Files Coverage Δ
src/cjs.js 0% <0%> (ø)
src/index.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 215fba7...0a77ec0. Read the comment docs.

Copy link
Member

@michael-ciniawsky michael-ciniawsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be good to go, the comments could be adressed or ignored and the follow up PR with standardize test setup just refactors/cleans them up. But #36 should land as soon as possible

@@ -0,0 +1,81 @@
import path from 'path';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should leave this out for now until there is consensus about the initial test setup

@@ -0,0 +1,81 @@
import path from 'path';
import webpack from 'webpack';
import Promise from 'bluebird';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please no extra lib for {Promise} as every supported target has native {Promise} support
promisify() can easily be polyfilled by a custom helper or a lightweight lib || utils.promisify()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below & I agree with you entirely. In fact I asked Sean about that shortly after looking at the example.

utils.promisify() iirc isn't available in all our supported Node versions so if we were going to use this setup ( and i'm not ) i was thinking about something like pify.

const stats = await run();

const { compilation } = stats;
const { errors, warnings, assets, entrypoints, chunks, modules } = compilation;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructuring here and returning an {Object} on L69 doesn't really make sense, its better to return the whole compilation and pass it to helpers in the particular test

example.test.js

import webpack from 'helpers/compiler'
import { loader, errors, warnings, assets } from 'helpers/utils'  // maybe test-utils/stats-utils

test('Loader', () => {
   const config = { loader: {...options} }

   webpack('path/to/fixture.ext', config)
    .then((compilation) => loader(compilation))
    .then({ result, map, meta } => {
       expect(result).toMatchSnapshot()
       if (map) expect(map).toMatchSnapshot()
       ...
    })
   .catch((err) => err)
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But thats discussion for webpack-defaults #68 to not derail the PR here further :)

});

test('should load scss file', async () => {
const { result } = await runLoadersPromise({ resource: getFixtureResource(fixtureName), loaders });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just two simple tests (default/escaping(#36)) with loader.call(ctx, content) for now as the raw-loader doesn't demand any requirements and proper testing in a follow up

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michael-ciniawsky - Yeah, I was just tinkering with Seans test setup which is complete overkill here but how cumbersome it was in a small repo was what I was curious about.

I'm going to lean this out a bunch more inline with your initial pass

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants