Skip to content

Conversation

@reznord
Copy link
Member

@reznord reznord commented Jun 23, 2017

Fix for #126

@rkostrzewski
Copy link
Collaborator

Travis build failed because we Skip installation of dependencies in tests. I'll look into enabling it & caching.

@reznord
Copy link
Member Author

reznord commented Jun 23, 2017

@rkostrzewski the tests failed in my local machine as well. Can you please have a look at the log?

https://paste.fedoraproject.org/paste/~djRyBcRUltRzRRaON3~qg

@developit
Copy link
Member

I wonder if falling back to require.resolve() if the file doesn't exist would work here

@reznord
Copy link
Member Author

reznord commented Jun 23, 2017

not sure how that is gonna fit in. Can you tell me how to get this problem fixed?

@lukeed
Copy link
Member

lukeed commented Jun 23, 2017

I think we just need to provide a path to the dev/module bundle? We can do this at the top of the config... something like:

let preact, type = isProd ? 'preact/dist/preact.min' : 'preact';

try {
  preact = require.resolve(type);
} catch (err) {
  throw err;
}

// ...

preact$: preact

Also, this is because I'm suspecting that env.cwd isn't being set correctly.


Not able to go thru this right now & debug what's happening, else I would! 😄

@rkostrzewski
Copy link
Collaborator

Nah, tests just skip npm install step to be faster.

@reznord the easiest way is to remove --no-install from here tough I'm afraid timeout will occur. I'll tinker around this tomorrow hopefully.

@reznord
Copy link
Member Author

reznord commented Jun 23, 2017

Can't we use yarn? It is much faster compared to npm. I know this is just going towards #15 😅

@rkostrzewski
Copy link
Collaborator

More like #31 😃

@reznord
Copy link
Member Author

reznord commented Jun 23, 2017

@rkostrzewski the suggestion by @lukeed works perfectly fine. Though that is more like a hack. If it is fine, I'll make another PR to the same with the patch by @lukeed.

I hope that will be fine.

@developit
Copy link
Member

developit commented Jun 23, 2017

Suggestion - we can use require-relative for this:

import requireRelative from 'require-relative';

// attempt to resolve a dependency, giving $CWD/node_modules priority:
function resolveDev(dep, cwd) {
  try { return requireRelative.resolve(dep, cwd || process.cwd()); } catch (e) {}
  try { return require.resolve(dep); } catch (e) {}
  return dep;
}

// ...
aliases: {
  preact$: resolveDep(isProd ? 'preact/dist/preact.min' : 'preact', env.cwd),
}

@lukeed
Copy link
Member

lukeed commented Jun 23, 2017

Yeah, we can. Is there a benefit here though? Plus I still have a feeling that env.cwd isn't set correctly

@developit
Copy link
Member

Hmm. If env.cwd isn't set, a lot of things should be blowing up. It should point to the directory where preact-cli was spawned, or the custom directory passed to the CLI in the case of tests and whatnot (ref).

The reason I suggested require-relative is so that if someone installs a specific version of preact or preact-compat, they'll get that version. I want to avoid people being stuck with whatever version we happened to ship with preact-cli. We'll want to take that into account when doing prerendering too - currently that uses the one we ship with as well.

@lukeed
Copy link
Member

lukeed commented Jun 23, 2017

Yeah, that's what I thought, but was having doubts looking at the travis logs here.

I agree. But in a Node 6+ environment, it's flat dep tree, so wouldn't a custom install overwrite what we ship? I'm inclined to think it does, since it's the same name (as opposed to a unique dep), but today also seems to be "just one of those days". 😴 😇

@developit
Copy link
Member

developit commented Jun 23, 2017

npm link creates non-flat trees, I actually think that might have been what @reznord was seeing originally. Interestingly, this webpack config option emulates kinda what I was going for with the cwd-first approach.

@reznord
Copy link
Member Author

reznord commented Jun 24, 2017

when I run npm run test it is opening up Google Chrome Canary. Any idea why that is happening?

@reznord
Copy link
Member Author

reznord commented Jun 24, 2017

In the travis log, this kinda caught my mind (https://travis-ci.org/developit/preact-cli/jobs/246455525#L1827) any idea why there are two instances of that?

@rkostrzewski
Copy link
Collaborator

@reznord it's opening Google Chrome because tests use it to verify if the app works correctly 😄. As for the warning with AudioManager - it doesn't matter at all (folks at lighthouse have that warning too).

@reznord
Copy link
Member Author

reznord commented Jun 24, 2017

@rkostrzewski cool. I have updated the PR. Can you please review it? As @developit suggested, I have added the require-resolve module and got it working.

Copy link
Collaborator

@rkostrzewski rkostrzewski left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

4 participants