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

Prevent inconsistent ember-cli builds with different extensions #166

Open
lifeart opened this issue May 16, 2019 · 7 comments
Open

Prevent inconsistent ember-cli builds with different extensions #166

lifeart opened this issue May 16, 2019 · 7 comments

Comments

@lifeart
Copy link

lifeart commented May 16, 2019

Maybe this is correct place for this issues collection, if not, feel free to close it or redirect me to proper repo.

ember-cli/ember-ajax#428
typed-ember/ember-cli-typescript#724
emberjs/ember-cli-babel#240

@stefanpenner
Copy link
Collaborator

I haven't had a chance to look at this yet, but seems important. If you have free time to provide a failing test, that would very much help me.

@dfreeman
Copy link

dfreeman commented Jul 31, 2019

@stefanpenner I'm not sure the best way to write a thorough test for this, since the issue is nondeterminism. As far as I know this same issue applies to the core broccoli-filter plugin as well.

If I write a plugin like this:

class MyPlugin extends PersistentFilter {
  constructor(input) {
    super(input, {
      extensions: ['foo', 'bar'],
      targetExtension: 'txt'
    });
  }

  processString(content, relativePath) {
    // Just write the extension of the input file as its content
    return path.extname(relativePath);
  }
}

And then run that over a directory that has both my-file.foo and my-file.bar in it, whether the resulting my-file.txt contains foo or bar depends on the order that files are processed in.

Concretely the way folks are running into this is with addons' app directories being merged together with the host's before running through Babel with multiple input extensions. If an addon and the host app both have files in their app tree with the same name, normally the order of the merge ensures that the app's file wins out, but if they have different extensions (i.e. when the addon's is .js but the app's is .ts), then the 'winner' just depends on what order they're processed in.

One way to solve this would be to have the order that extensions are specified in indicate the precedence if multiple files collide. I have no idea how easy that would be to implement, though, given the layers of caching and concurrency here 🤔

@runspired
Copy link

runspired commented Nov 19, 2019

This might be the underlying reason for emberjs/data#6697

We changed the file from a .js extension to a .ts extension, at which point these errors began being reported. Doing a clean build won't reproduce.

@lolmaus
Copy link

lolmaus commented Jan 20, 2020

This issue hits us really hard on all our TypeScript projects.

We can work around it with our own addons, but there's nothing we can do with third-party addons, other than forking them. 😕

Due to this issue, ember-cli-typescript randomly fails to override services from infrastructural addons such as ember-intl, ember-simple-auth. The app would crash for some developers with an error that gives no clue.

Is anyone working on this?

Copy link
Member

rwjblue commented Jan 22, 2020

No, not to my knowledge

@chriskrycho
Copy link

We've worked around this in ember-cli-typescript using broccoli-stew's afterBuild hook, but it's not great (and may have performance implications?). What would a solution here actually look like?

@knownasilya
Copy link

Still an issue today. Does Embroider v2 package format remove this problem?

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

No branches or pull requests

8 participants