GithubHelp home page GithubHelp logo

Comments (11)

mjackson avatar mjackson commented on April 26, 2024

This has honestly been really frustrating for me too. Let me explain how things are currently setup, and hopefully we can figure out a better way to do things.

Our build isn't really that strange–it's just a single babel transpile step, which is quite common nowadays, especially in the React community. We use npm's prepublish script to create the build, which AFAICT is in accordance with npm's script guidelines for running a build step that transpiles one language to another (e.g. CoffeeScript).

The problem in this case is that, although npm runs prepublish on a local npm install, it won't do that for remotes (like GitHub). So, yes. Installing from GitHub is broken.

Perhaps @othiym23 has an idea how we can improve this...

from history.

mjackson avatar mjackson commented on April 26, 2024

I guess we could use a postinstall hook that generates the lib directory if there isn't one already. That might work.

from history.

mjackson avatar mjackson commented on April 26, 2024

Either that or we could check our lib directory into git. But I'd prefer to avoid that.

from history.

gaearon avatar gaearon commented on April 26, 2024

Note even with postinstall it's a bit tricky. See how Radium does it.

cc @ianobermiller who knows why it's done this way.

from history.

mjackson avatar mjackson commented on April 26, 2024

@gaearon Ya, that's exactly what I was thinking.

Basically, if the lib directory is missing then we know we were not installed from the npm package. So build it.

from history.

jeffreywescott avatar jeffreywescott commented on April 26, 2024

Wow. Thanks for the quick turnaround on this, guys. Not sure if that commit fixed it (I haven't tried it), but I'll give it a try and let you know.

from history.

mjackson avatar mjackson commented on April 26, 2024

@jeffreywescott Nah, that commit doesn't actually fix the problem because the modules directory is in our .npmignore. npm currently doesn't handle the transpilation use case very well at all it seems :/

In short, we could fix remote installs but it would mean that we now have to include the ES2015 source (the modules dir, and probably our .babelrc too) in our npm package. I dunno. Maybe that's something we actually want to do. Use lib for our build, modules for the source. There are a few niche tools that actually support running ES2015 nowadays, and that crowd is only going to get bigger.

from history.

gaearon avatar gaearon commented on April 26, 2024

it would mean that we now have to include the ES2015 source (the modules dir, and probably our .babelrc too) in our npm package

I started doing this, and I think it's the way to go. Some people want to look into uncompiled code, or even use ESnext env. And it handles this use case too. Go for it!

from history.

jeffreywescott avatar jeffreywescott commented on April 26, 2024

Hey, guys.

I just tried this again today, and things are still not working. I thought the reason why was that package.tgz does not include the .babelrc file that's necessary for building:

$ npm install
/
> [email protected] postinstall /Users/jeffrey/dev/wisdomlabs/wisdomlabs-com/node_modules/history
> node -e "require('fs').stat('lib', function (e, s) { process.exit(e || !s.isDirectory() ? 1 : 0) })" || npm run build


> [email protected] build /Users/jeffrey/dev/wisdomlabs/wisdomlabs-com/node_modules/history
> babel ./modules -d lib --ignore '__tests__'

modules/Actions.js -> lib/Actions.js
modules/AsyncUtils.js -> lib/AsyncUtils.js
modules/DOMStateStorage.js -> lib/DOMStateStorage.js
modules/DOMUtils.js -> lib/DOMUtils.js
modules/ExecutionEnvironment.js -> lib/ExecutionEnvironment.js
modules/createBrowserHistory.js -> lib/createBrowserHistory.js
modules/createDOMHistory.js -> lib/createDOMHistory.js
modules/createHashHistory.js -> lib/createHashHistory.js
modules/createHistory.js -> lib/createHistory.js
modules/createLocation.js -> lib/createLocation.js
modules/createMemoryHistory.js -> lib/createMemoryHistory.js
modules/enableBeforeUnload.js -> lib/enableBeforeUnload.js
modules/enableQueries.js -> lib/enableQueries.js
SyntaxError: modules/index.js: Unexpected token (1:7)
> 1 | export createHistory from './createBrowserHistory'
    |        ^
  2 | export createHashHistory from './createHashHistory'
  3 | export createMemoryHistory from './createMemoryHistory'
  4 | export createLocation from './createLocation'

npm ERR! Darwin 14.5.0
npm ERR! argv "/Users/jeffrey/.nvm/versions/io.js/v2.4.0/bin/iojs" "/Users/jeffrey/.nvm/versions/io.js/v2.4.0/bin/npm" "run" "build"
npm ERR! node v2.4.0
npm ERR! npm  v2.13.0
npm ERR! code ELIFECYCLE
npm ERR! [email protected] build: `babel ./modules -d lib --ignore '__tests__'`
npm ERR! Exit status 1

However, even adding --stage 0 --loose to the npm build script in package.json didn't seem to help.

Any ideas?

from history.

mjackson avatar mjackson commented on April 26, 2024

AFAICT you need to use --loose all @jeffreywescott, not just --loose.

from history.

mjackson avatar mjackson commented on April 26, 2024

I just confirmed that with --loose all it works, @jeffreywescott. I'll push an update to master.

from history.

Related Issues (20)

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.