-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Switch to new ES6 style modules in Excalibur #606
Comments
I wholeheartedly agree. It'll be better in the long run. On Thu, Jun 16, 2016, 21:34 Erik Onarheim [email protected] wrote:
|
Is this already being worked on? If not, I can send a PR. |
Hi @soncodi, this is not yet being worked on. However, this will be a very large and difficult change as it will touch most every file in the Excalibur code base and require changes to the build process. If you'd like to contribute to Excalibur, we recommend looking at issues labeled "jump-in" to help familiarize yourself with developing for this project. Please review our contributing guidelines. A few things that you will run into if you work on this issue:
|
As mentioned in #675 could we add the required lines to add compatibility to module loaders as a quick stopgap? |
I might take this on during holiday break in the next couple weeks for 0.9. |
Is there a shared branch we can set up to work collectively on this task? There are a ton of files to change, and I'm happy to help with some, but I don't want to double up efforts. |
I was going to create a branch yesterday but didn't yet--if you want to create one, I was going to go with |
@kamranayub, I've been looking into this, and there's not going to be an easy way to break it up. As soon as you change one Unless someone else knows of a way to use both an import and triple slash reference in the same file? I've been striking out. |
Yeah, that's why I was going to handle doing this in one fell swoop sometime next week ;) But it's cool you took a swing at it! Don't feel like you have to tackle this bad boy, there are other easier issues that are up for grabs too. |
@kamranayub, yea, I was just hoping to find a way to be able to do it incrementally. I've led projects with massive changes like this before, and unless they can be automated to help minimize merge conflicts, they're quite a pain. I'll take a look and see what else is outstanding. |
There's another wrinkle with this issue. While it will be possible for us to switch to a module system and still output to a single file, one outstanding issue is that the generated declaration files are not "flattened" meaning that the generated concatenated declaration file may expose internal/private modules. It's not a dealbreaker but it is annoying. There's an open PR for it: microsoft/TypeScript#5332 |
OK, I'm about ready to throw in the towel. Here are the problems converting the entire codebase to modules:
I think that we could possibly move to a module syntax--in fact, I've converted the entire engine over in my branch and everything compiles. But due to this weird circular dependency issue, it's going to be a bear to fix and it will be a breaking change. @excaliburjs/core-contributors I don't know what you guys want to do. On one hand, it might be nice to fix the smells of circular dependent code but on the other, it's all over the codebase because Ex is a global library. We could wait for 1.0 and do a major re-tool of the codebase, doing modules in the process. We could throw in the towel and keep using an internal module like we are now. I could also try just cleaning up the triple-slash references--I might be able to use the tsconfig or a single The goal of doing this was to clean up the code but it ends up complicating the build process immensely--there's no way to avoid adopting a bundler, whether that's RequireJS + Almond, SystemJS + JSPM, Webpack, or Browserify. In the end, we just want to make it easier to use Excalibur in a module environment--so maybe instead we should just focus on creating templates for the common use cases we see from folks (Angular, Webpack, CommonJS, etc.) and provide the right guidance. I could also easily add a UMD header to the output JS to support CJS and AMD module loaders. |
UPDATE I got it working! Turns out the circular dependency rabbit hole was not deep at all--the only problematic class was Actor because it had a few lines that depended on its sub-classes UI Actor, Trigger, and Label. I think we can eliminate that dependency, I have a proposed fix. I also was able to re-export the entire public API without too much hassle in a set of |
Closes #606, Closes #733, Closes #717 ## Changes: - Changed internal Excalibur code into modules (ES6 style) - Excalibur uses UMD module style for distribution (supports CommonJS, AMD, and window global) - Bundled AMD modules using Almond.js micro loader - Added two declaration files to dist, `excalibur.d.ts` and `excalibur.amd.d.ts` - Added AMD bundle to distribution `excalibur.amd.js` - Added inlined source maps for browser debugging - Cleaned up Gruntfile and various compilation tasks
Context
Currently, we are using the old
/// <reference path="./path/to/my/module"/>
syntax. This is old and clunky and it seems like VSCode has a hard time interpreting modules and dependencies.Proposal
I propose we move to the new ES6 style module syntax (commonjs) that is now available in the TypeScript compiler so that dependencies look like this
We just need to set the module style in the compiler settings to
commonjs
This will be a pretty large task since it will need to touch most all files in Excalibur
The text was updated successfully, but these errors were encountered: