Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preact): fix umd export for preact #169

Merged
merged 1 commit into from
Sep 2, 2017

Conversation

razh
Copy link
Contributor

@razh razh commented Sep 2, 2017

What: Use preact as the global for the UMD preact bundle instead of react.

Why:

The UMD build of preact references a global.React:

// umd
(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('preact')) :
	typeof define === 'function' && define.amd ? define(['preact'], factory) :
	(global.Downshift = factory(global.React));
}(this, (function (React) { 'use strict';

/* ... */

})));

https://unpkg.com/downshift@1.3.0/dist/downshift.preact.umd.js

When targeting preact, rollup-plugin-alias changes all react module references to preact:

// cjs
var React = require('preact');

preact isn't provided as a global to rollup, so for the UMD build, rollup guesses React based off of the variable name.

Before

import React from 'react'
/*                   │

            rollup-plugin-alias

                     ▼                    */
import React from 'preact'
/*       │

         └── rollup guesses from ───┐
                 variable name      │
                                    ▼     */
global.Downshift = factory(global.React)

After

import React from 'react'
/*                   │

            rollup-plugin-alias

                     ▼                    */
import React from 'preact'
/*                   │
              rollup looks up
               in `globals`
                     └──────────────┐
                                    ▼     */
global.Downshift = factory(global.preact)

How:

Declare preact as a global instead.

Checklist:

  • Documentation N/A
  • Tests N/A
  • Ready to be merged
  • Added myself to contributors table N/A

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Thanks!

@kentcdodds kentcdodds merged commit ce41f86 into downshift-js:master Sep 2, 2017
@codecov-io
Copy link

Codecov Report

Merging #169 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #169   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      4           
  Lines         267    267           
  Branches       64     64           
=====================================
  Hits          267    267

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 2e8d0ae...1618f45. Read the comment docs.

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

Successfully merging this pull request may close these issues.

None yet

3 participants