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

Filenames of resources must be unique to avoid a crash #65

Closed
baboons opened this issue Nov 26, 2018 · 5 comments
Closed

Filenames of resources must be unique to avoid a crash #65

baboons opened this issue Nov 26, 2018 · 5 comments
Labels
bug Something isn't working

Comments

@baboons
Copy link

baboons commented Nov 26, 2018

Considering the examples for NCC with Apollo and an abstract structure with schemas as resources and sharing the same filenames. This will cause NCC to compile the first/last file only, and throwing an error.

schemas\
      blogs\
           index.js
           schema.gql
      posts\
           index.js
           schema.gql

Output

   3kB  /schema.gql
6127kB  /index.js

At the moment this can only be resolved by renaming one of the schemas and make sure the file names are unique:

const typeDefs = String(fs.readFileSync(__dirname + "/schema2.gql"));

Output

   1kB  /schema2.gql
   3kB  /schema.gql
6127kB  /index.js
@TooTallNate
Copy link
Member

Duplicating the original directory structure would be another way to solve it (would still require a rewrite of the output file path).

@TooTallNate TooTallNate added the bug Something isn't working label Nov 26, 2018
@guybedford
Copy link
Contributor

There is deduping applied in https://github.com/zeit/ncc/blob/master/src/asset-relocator.js#L40 which should exactly be resulting in schema and schema1 being emitted.

I suspect this may actually be due to a static analysis failure as opposed to a deduping failure - where one is not being statically analyzed and the other is, but we won't know until we can verify the exact JS expression that loads both of these.

@guybedford
Copy link
Contributor

@baboons do you have an exact replication here that we can look at?

@guybedford
Copy link
Contributor

(duplicate assets are already unit tested in https://github.com/zeit/ncc/blob/master/test/unit/asset-fs-inlining-multi/input.js)

@rauchg
Copy link
Member

rauchg commented Dec 3, 2018

I'll close until we hear from @baboons whether this is happening on 0.3.0+

@rauchg rauchg closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants