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

Vite #1261

Closed
wants to merge 7 commits into from
Closed

Vite #1261

wants to merge 7 commits into from

Conversation

NullVoxPopuli
Copy link
Owner

@NullVoxPopuli NullVoxPopuli commented Aug 19, 2023

Blocked on browser support for <template> compilation.

Mainly (sortof?),
we need to remove commonjs packages because Vite isn't as friendly with them.
otherwise, we run in to errors in vite, like: "ambiguous indirect import", which, if you control the source code, you can work around via import * as cjsBlergh from 'its-2023-comeon'.
So, I can understand now why maybe @ef4 wanted embroider cross-compiling to cjs and esm -- esm just makes things easier. I should finish that PR 😅

I ran in to the cjs compatibility issue when I was trying to use my old copy of ember-template-imports, which uses

  • babel-import-util
  • magic-string -> encode
  • probably etc

so, ideally, I'd just not use those,
there are two paths to browser-support for <template> compilation atm:

  • ember-template-tag (@patricklx has been doing a ton of work to make working with <template> way easier in lint tools and stuff
    • this is currently blocked on actually shipping a browser-compatible bundle / module tree (last attempt here ) -- and waiting release of ember-template-tag to npm
  • Enable browser / cross-platform support embroider-build/content-tag#18
    • the last attempt is here -- it does need a manually linked version of content-tag (or custom git branch) -- but it doesn't actually work because webpack is weird
    • with vite though, we get Uncaught SyntaxError: ambiguous indirect export: Preprocessor as well :( so.. this is oof. maybe there is a vite config to change somethere?
      UPDATE: solved by fixing the package.json (. import specifier were in the wrong order)
    • additionaly the wasm version is very big -- around 1 MB. Which, if I only needed that 1MB, that'd be stellar -- but right now I'm using babel-plugin-ember-template-compilation, proposal-decorators (legacy), and proposal-class-properties -- once all 3 of those are available in SWC, maybe there can be a small WASM-version of the full compilation process, and I can ditch babel (which is currently overall closer to 5MB)

Note that these errors are the same:

  • Chrome: The requested module does not provide an export named
  • FireFox: ambiguous indirect import

On the vite cjs problem, I've found this information:

There are a ton of issue reports with this error: https://github.com/vitejs/vite/issues?q=is%3Aissue+The+requested+module+does+not+provide+an+export+named+is%3Aclosed

Looks like, for the issues that have resolutions, the solution is different for each.

I remember reading that one of the solutions was to hoist dependencies -- which is super dirty -- I instead changed babel-plugin-ember-template-compilation to a peerDep of ember-repl, but the problem persists.

but after doing this, I moved babel-plugin-ember-template-compilation back to optimizeDeps.include, and I made progress -- now it seems decorators aren't getting transpiled. hmm

Uncaught Error: Assertion Failed: @link is a stage 1 decorator, and requires a descriptor

lol, this is my own error, and means it's getting called incorrectly
Though, there is a third argument -- but it's undefined -- I guess I wasn't expecting the descriptor to ever be undefined 🤔
image

@stackblitz
Copy link

stackblitz bot commented Aug 19, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Aug 19, 2023

⚠️ No Changeset found

Latest commit: 87a72ae

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@NullVoxPopuli
Copy link
Owner Author

Closing as all the blockers are dealt with, but now the vite template has changed enough where it's easier to just start over

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.

None yet

1 participant