-
-
Notifications
You must be signed in to change notification settings - Fork 517
feat(typescript-webpack-experimental): new experimental version of the webpack skeleton #714
Conversation
Wow @niieani this is fantastic. Seriously, great work. Excited for server-side rendering and hot module replacement additions. |
@niieani really great work. Webpack config is easy to read and understand. Can't wait for the hot module replacement. Thanks! |
@niieani Great work. Thank you for the great efforts. Now anticipating the server-side rendering. Anything experimental also for ESnext? |
Am I the only who looks at the skeleton files (specially I really acknoweldge the efforts and optimizations done here by @niieani, but unless this is simplified or a walk-through documentation is provided (that shows how |
@niieani Should @easy-webpack/core still be a dependency in |
@mttmccb @nashwaan I've tried to reduce the number of technologies used here, compared to the old skeleton. However the number of dependencies is still large because of all the basic loaders and Webpack plugins, and then the testing environments (although jest requires much fever than karma). This is the bare minimum for a modern SPA project with unit and e2e testing. Have a look at the React boilerplate or Angular2 skeletons. They have a similar, if not larger number of dependencies. Config file is simplified and easy to remove features, although there are barely any to remove - it's set up for a simple build system for both development and production builds, and that's all. |
From Gitter:
@stevies converting the TS skeleton to use babel should be very easy, I didn't do it yet just because it would be too much maintaining for an "experimental" skeleton. After we get feedback and iron out any remaining bugs we can get a JS skeleton running. |
@smithaitufe I think the reason is that your project had unlocked SemVer for the Webpack dependencies, and since there were some breaking changes in the recent webpack betas, a new If you want to further reply to this matter, please open a separate issue or ask on Gitter, this PR is about something else. |
@EisenbergEffect Any idea when this will be completely merged and transformed over to ESnext? My project is currently rocking a hefty 22mb 0.chunk.js file and I would really love to use the new code splitting feature asap. I'd be happy to test it out for you guys as soon as I had an ESnext version I could plug into my project. |
Within a week I hope. Things could come up in testing. We need to review and fix up a few more things first too. |
@niieani Hi, I tried your experimental skeleton and on Windows 10 after lunch
|
@lares83 the repo is not ready to be tested yet, it's waiting on some PRs to get merged. Also, it's probably not Windows ready yet. We'll let you know as soon as it's possible to try it out. |
I just wanted to report back that I was able to get this running on my mac without errors. I do look forward to an official release though that I can migrate over. After looking into the router config I don't see any of the @lazy code chunking examples. @niieani Can you add an example or provided some docs on how that will work so I can run a test? |
@jasonbiondo there's an example for how to do code chunking in the first post of this PR. To reiterate, add a special comment directly before the module name you are requiring, e.g. like this: /* @import @lazy @chunk('some-chunk') */ './my-module'
You may combine This might be most useful in your router. You can also create chunks / lazy-loaded chunks by listing the paths in your That hasn't changed, but paths now support 2 simple globbing patterns:
e.g.:
One caveat: when using globs, you must add the extension. If a file is listed as build resource, that's considered the single point of truth, and the comment imports are ignored (it takes precedence AND overrides). |
@niieani Thanks for the update. I edited the app.ts file and ran a build but I'm not seeing the chunk file being created. This is the change I made:
Was that correct? Shouldn't the some-chunk file be created? |
@jasonbiondo your change is correct. Not sure why it wouldn't work since it works on my end. You could instead try defining the chunk in "resources": [{ "path": "users", "lazy": true, "chunk": "some-chunk" }] Let me know if that works. I'd wait until we merge the remaining PRs and we can all do a bit of proper testing of the new stack. I might make the |
@niieani I'm getting a warning in terminal with adding that in as well. Also the file is still not created upon completion. Here is full trace:
Here is the change on my end:
|
@jasonbiondo yep, the problem is that you're not using the latest version of the |
@niieani I see. I cloned the loader-webpack, changed the name to aurelia-loader-webpack and moved it to my node modules dir but I'm still getting the error. |
@jasonbiondo because the loader is not built. You don't need to clone manually, npm install github:aurelia/loader-webpack#experimental-release --save-dev |
@niieani any idea why this is invalid? Jasons-MacBook-Pro-2:skeleton-typescript-webpack jasonbiondo$ npm install github:aurelia/loader-webpack#experimental-release --save-dev |
Looks like you have loader-webpack twice, once the 2.0.0 version, once from the old I think it will be easiest if you simply wait a few more days for the related packages to be released and then try the skeleton again. |
@niieani, fantastic work! So i have an idea for improvement: I'd propose using special functions that takes the module id and simply returns it at runtime, but for aurelia webpack support we'd be able to pass in additional arguments (modifiers/hints), that would be read by build system at build-time, and that would be ignored at runtime. Also this function could be documented, so whoever looks at its documentation (for example in TypeScript declaration file) would understand what it is used for without having to wonder what is encoded into the comments and who might use/need them. For example, I came up with few alternative syntaxes that I might prefer over using comments: import {wp} from 'hypothetical-aurelia-webpack-extension';
...
wp.moduleId('./users', {
import: true,
lazy: true,
chunk: 'some-chunk'
}),
...
import {wp, IMPORT, LAZY} from 'hypothetical-aurelia-webpack-extension';
...
wp.moduleId('./users', IMPORT | LAZY, 'some-chunk'),
...
@niieani, what do You think? |
@atsu85 I have thought about this for a while, and while comments are not the best, they're in some ways better than special functions (which I've also thought about). The problem is, when you use special functions your code is not portable anymore. I was hoping that with the new skeleton, you can run the same code, without any changes (aside from configuration), with Aurelia CLI, RequireJS, SystemJS, JSPM, etc. Once we start adding functions which are loader-specific, we loose portability. There's indeed an alternative, we could create a simple function which returns the same string, i.e. in the simplest form: function dynamicImport(moduleId) {
return moduleId;
} Then the parser would look for This is the other relatively good solution I could get behind of, since it wouldn't break other-module compatibility. But when switching / using other loaders, you'd end up with an unnecessary call to a function in the output build. Maybe that's not such a big problem. I'll need to think about it some more. |
Thank you @niieani! |
Appears to be broken - skeleton-esnext-webpack - downloaded from master, running on: Windows 10 Ran: yarn install Removing Bluebird from main.js fixes it:
Same issue using Ubuntu. Node 6.9.4 |
@niieani I am using module.exports = ({production, server, extractCss, coverage} = {}) => ({ I am used to Also, I get failing unit-test cases on anything using async/await syntax. Do these lines need to be transpiled by |
I'll have a look at unit-test cases. |
@niieani and team, awesome job here. I will be working to recreate my apps within this new skeleton over the next week. A few suggestions: "aurelia-tools": "^1.0.0", update the babelrc line 10 to be Thanks! |
@JoshuaVSherman, my first thought was: why would You like to add babel and eslint to typescript project? Because normally You would use either typescript compiler or babel (tough there were times when TS wasn't able to generate ES5 code for async, in which case TS->ES6->Babel served as workaround) and either tslint or eslint. Are they related to running tests with jest? |
sorry, i was replying without noticing that this was regarding typescript
I am not using typescript
…On Tue, Apr 11, 2017 at 3:13 PM, atsu85 ***@***.***> wrote:
@JoshuaVSherman <https://github.com/JoshuaVSherman>, my first thought
was: why would You like to add babel and eslint to typescript project? *Because
normally You would use either typescript compiler or babel (tough there
were times when TS wasn't able to generate ES5 code for async, in which
case TS->ES6->Babel served as workaround) and either tslint or eslint.*
Are they related to running tests with jest?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#714 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMuN2McclL4_gwFinUmCVCCQSQQ6ExqFks5ru9DfgaJpZM4Kw1ol>
.
--
Josh Sherman
www.joshandmariamusic.com
|
Is it only me that can't get skeleton-esnext-webpack working? |
did you start all over or are you trying to incorporate changes into your
existing one?
I decided to just start all over and slowly merge my code back into the new
skeleton
…On Tue, Apr 11, 2017 at 4:23 PM, stevies ***@***.***> wrote:
Is it only me that can't get skeleton-esnext-webpack working?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#714 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMuN2AEoKDZtJLjWQOV99ene0PFSx6qGks5ru-E4gaJpZM4Kw1ol>
.
--
Josh Sherman
www.joshandmariamusic.com
|
Starting from clean installation - see comments above from 2 days ago. |
i'm using node 7.8.0 https://github.com/aurelia/skeleton-navigation/blob/master/skeleton-esnext-webpack/package.json |
I was able to update my projects with the latest releases, only thing not working is SCSS files, I get:
In Do I need special configuration to import SCSS/CSS files? |
|
@Thanood I had the same issue and decided against more head scratching and added all of my scss imports to the viewmodel. Not a real solution though... I recall there was an indication that style imports were going to be added as a convention so that a.html, a.js and a.css would be loaded by default in this skeleton? |
Thank you @Thanood for the workaround, unfortunately I cannot change that module. Any way to fix this in @niieani is the plugin actually supposed to import template's |
With proper loaders config and |
I am also seeing strange things with my CSS imports. What worked before is
no longer working. I had to inline a bunch of styles yesterday for my
aurelia-table
…On Apr 21, 2017 7:35 AM, "jods" ***@***.***> wrote:
<require from="./entity-select.css" as="scoped">
you mean entity-select.scss, right?
With proper loaders config and ***@***.*** it
should work.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#714 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMuN2AwloM-Uei6j-ploVqiMbtBSvTS9ks5ryJRzgaJpZM4Kw1ol>
.
|
@jods4 I use the |
@heruan support for |
Hm, in fact requiring the
with this loaders: module: {
rules: [
{ test: /\.tsx?$/, use: [ "awesome-typescript-loader" ] },
{ test: /\.json$/, use: [ "json-loader" ] },
{ test: /\.html$/, use: [ "html-loader" ] },
{ test: /\.css$/, use: [ "style-loader", "css-loader" ] },
{ test: /\.scss$/, use: [ "style-loader", "css-loader", "sass-loader" ] }
]
} @jods4 Any hint or doc on how to configure loaders for |
I don't think this is a loader problem. Where is |
In the same directory where the view-model and the template are:
and then
Since |
Yup. But you have a *.css file there, not a *.scss! |
|
I got it working with the |
If it's a lib you distribute and you don't want to impose a SASS loader to your users then you should consume CSS indeed. The fact that we can now require SASS or LESS directly is especially interesting for apps source code, I think. |
Locking this so that people don't get emails for any more comments. If you're having problems with the new skeletons, please open issues, write on Gitter or create questions on Stackoverflow. Thanks for all your feedback and help! |
This PR contains support of the Aurelia & Webpack duo, rewritten from scratch, solving over 20 Webpack-related issues, at the same time deprecating these dependencies:
They're simply no longer needed.
New features:
integrates @MeirionHughes' template linter out of the box(decided against in the end, not prime-time ready)uses jest with the aurelia-pal-nodejs and the new aurelia-loader-nodejs,
instead ofalong with karma, for blazing fast, modern and easy unit testingintegrates and gives an example for testing with aurelia-testing (see
test/unit/welcome.spec.ts
)leverages jest's snapshot testing (in short: save rendered template HTML as text to a file, and then compare the rendered output with every run of the test; popular in the React circles), example also in the
welcome.spec.ts
drops @easy-webpack configs in favor of a flat, yet still simple Webpack config file
Webpack now understands the dynamic nature of dependencies in Aurelia, thus the dependency graph is now very accurate. Aside from the old way of defining dependencies for Webpack,
aurelia.build.resources
in package.json which can still be used to define bundles, declaring dynamic dependencies is now much simpler, can can be achieved by simplyplacing a comment directly before the module ID literal. For example:DEPRECATED, see Proposal: PLATFORM.bundle / moduleIdFor pal#17 for updated exampleoutdated example
There are two modifiers that you can add to the comment,
@lazy
and@chunk('some-name')
:This is all you need to make a separate, lazily loaded bundle which contains a given route and all of its dependencies. No other configuration needed.
simple glob patterns (single*
and double**
) are now supported for adding/matching dependencies in build resources and importing from code(e.g./* @import('./path/*\/.js') */
)related
.html
and.css
files of the same name as the ViewModel are now included as its dependencies by convention, you may configure additional extensions or other conventions by passing a method in the Webpack configuration filehot reload for CSS imported in JS files works
beta version of hot reloading both Views and ViewModels
I'm marking this "experimental", since everything about this is a "breaking change" and it needs further testing by other people to iron out possible bugs. I've tried best I can to test this thoroughly, but it's still pretty fresh. Also, there are no docs written yet, especially for the webpack-dependency-suite, a collection of plugins and loaders which I've written with Aurelia in mind (but they're generic, hence deprecation of aurelia-webpack-plugin).
All this work was also prep for two more features that will now be possible:
Comments are welcome.
This skeleton won't work until the dependent PR's are merged and published to NPM as new versions.
@EisenbergEffect This PR is blocked by:
bnr
andconcurrently
dependencies