Giter VIP home page Giter VIP logo

p-defer's Introduction

Hello. I'm Sindre. I like code. Thanks for reading.

p-defer's People

Contributors

bendingbender avatar callmehiphop avatar coreyfarrell avatar richienb avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p-defer's Issues

Build failed on create-react-app@1 because the published package is not ES5 compliant

When I am importing p-defer in create-react-app@1 (with [email protected]), then run npm run build. I got the following error "Failed to minify the code from this file: p-defer/index.js:2".

The primary reason is because index.js is not ES5-compliant (use of arrow functions). If I modify two "arrow functions" into traditional one, it will pass create-react-app build.

'use strict';
module.exports = function () {
	const ret = {};

	ret.promise = new Promise(function (resolve, reject) {
		ret.resolve = resolve;
		ret.reject = reject;
	});

	return ret;
};

On the other side, create-react-app@2 changed the behavior and it will start building ES6+ files under /node_modules/. So it do not repro in create-react-app@2. But unfortunately, create-react-app@2 was just released in October 1st 2018. I bet there are lots of projects still running under create-react-app@1 and will keep it that way for another 1-2 years.

I am unsure if p-defer should be ES5 or ES6 compliant by default. NPM don't have a strict guideline. So I will leave it open for the contributors to decide how to resolve this issue.

Error from npm run build of react-scripts:

> react-scripts build

Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file:

        ./node_modules/p-defer/index.js:2

Read more here: http://bit.ly/2tRViJ9

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

ESM error in v4

I get the following error when using [email protected]. The error is explicit, and offers 2 possible solutions.

Error: Must use import to load ES Module: /home/yosbel/Documents/experiments/procplay/node_modules/p-defer/index.js
require() of ES modules is not supported.
require() of /home/yosbel/Documents/experiments/procplay/node_modules/p-defer/index.js from /home/yosbel/Documents/experiments/procplay/.next/server/pages/_app.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/yosbel/Documents/experiments/procplay/node_modules/p-defer/package.json.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.