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
Meteor 1.3 *early beta* (ES2015 modules, better file load order control, and more) #5788
Comments
Thanks for that! Looking forward to test modules! 👍 |
Great work! Really excited about it, really cool that we can start getting rid of creating wrapper packages for npm stuff. 👍 |
This seems to work great, thank you mdg. |
Nice. |
Before you release the new module system, please make it compatible with CoffeeScript. In CoffeeScript, `import Ember from 'ember'`
DummyController = Ember.Controller.extend()
`export default DummyController` A simple solution is to follow the example of the ember-cli-coffee6 package, that does some simple string parsing to fix Coffee-style |
@avital Is import/export supposed to work from jsx? I've added the react meteor package but when using import/export from within jsx I get an error about usage of a reserved keyword. |
@benjamn How do you feel about relative vs absolute file imports? It frustrates me when I have to write something like I saw your really nice presentation on ES6 modules and I'm curious what you think about this. Will this be supported in Meteor? How would this sort of thing work when publishing packages? |
@ccorcos there's been some debate about whether we should support module identifiers starting with a Now for the caveats… In Node, an absolute module identifier corresponds to an absolute path from the root of the file system. Because we definitely don't want to include path prefixes like Instead, absolute module identifiers refer to the root of the virtual directory structure installed by import Something from '/app/lib/some/thing'; if you wanted to avoid The situation with packages is similar, but somewhat more complicated-looking, because Meteor packages get installed with import PackageThing from '/node_modules/some-meteor-package/some/thing'; On the other hand, because of this structure, you probably never need to use an absolute module identifier to refer to a package, because you can just treat it as a top-level npm package: import PackageThing from 'some-meteor-package/some/thing'; In other words, the |
@benjamn thanks for the explanation. Feeding off your presentation, I'm curious about this from a more generic sense -- how can this be compatible within Meteor and the rest of the NPM / Javascript community. For example, within my webpack config, I simply tell it where it resolve absolute paths from: resolve: {
root: [
path.resolve(__dirname),
],
modulesDirectories: [
'node_modules'
]
} Then I don't even have to use the leading slash (which is ambiguous with the root of the filesystem as discussed): import Something from 'app/lib/some/thing'; And by specifying the modulesDirectories, I can get away with this as well: import PackageThing from 'some-meteor-package/some/thing'; The big caveat left in both the Meteor and the large Javascript community is that if I produce a package that uses these absolute paths (relative to the package's root), and then I start using it within another project, the packaging system needs to know what the package absolute paths are relative to the package root and not the project root. I believe this is still not a solved problem within the Webpack community. @benjamn I'd also like to hear your thoughts about webpack's approach to bundling static assets (CSS, SCSS, Images, Fonts, SVGs, etc) within Javascript. |
👍 |
Won't this feature also make it possible (or make it easier) to introduce bundlers, like Webpack? I'm especially concerned about build times, which would greatly benefit from tools like Webpack. |
@GeoffreyBooth Why are |
I don't think this is a the best way to go, for some reasons:
Additionally, some things that might help:
|
@ccorcos Also brought up a good point about the absolute paths and the meaning of it changing when using libraries in different environments. I think that the use of absolute paths should generally be discouraged in Meteor's case.
This is what packages the provide compilers will continue to be used for. For example, the
Nope, not at all. We can do that already, right now, without Meteor 1.3 (for example, my |
@trusktr I see, interesting. I'll have a look at your implementation for getting some ideas. Thanks! :) |
I like this approach. You'd effectively need to symlink your project into
I guess your right, actually. But then we have a similar problem as before where we have to create all these package shims. Theres a huge selection of webpack-loaders that are really nice to use:
|
You wouldn't have to, the I agree, there's tons we can do with Webpack that we won't immediately be able to do with Meteor 1.3. One thing (as you allude to) is that Webpack laoders don't just transform code, they also specify how to write import/require statements. So, even if Meteor 1.3 has compiler packages, there would still need to be an something additional implemented to let Meteor 1.3's |
Still, the name import Something from 'meteor:app/lib/some/thing' ? |
What if it were just the name of your package? |
Then that's what it would be! ;] |
@trusktr, I’m glad that ES2015 is here and catches up to CoffeeScript with regards to the features that tempted many developers to CoffeeScript years ago. Many of those developers have switched back to ES2015, and more power to them; I’ve been using CoffeeScript for years primarily for the easier-to-read syntax, for the breath of fresh whitespace I get from fewer braces and parentheses and semicolons, and I don’t intend to stop coding in CoffeeScript just because JavaScript no longer sucks so much. So please give us CoffeeScript diehards a way to use ES2015 modules in Meteor. Backticking ES2015 code in JavaScript is a pretty shitty solution, ugly and prone to error because you’re asking people to mix ES2015 and CoffeeScript in the same file. I think ember-cli-coffees6’s approach, letting me write Or if anyone knows @jashkenas or @michaelficarra or @satyr or @lydell or @alubbe or any of the other CoffeeScript maintainers, please convince them to stop ignoring this issue. |
Just to clear some confusion regarding CoffeeScript:
(Also, I don't see how using backticks is prone to error (but I agree that it is ugly): `import {a} from 'a'`
b = ->
a()
`export b` The code in backticks are just "static declarations".) Unsubscribing. |
Personally, I believe CoffeeScript should be a whitespace-based improvement of JavaScript, which should now include the finished ES6 syntax incl. import/export. That's why I built and lobbied for generator support - but as @lydell mentions, it's up to @jashkenas If you really want to see it in CoffeeScript, I'd suggest to build it yourself and open a PR. |
Anyone else having trouble with 3rd party libraries. created a shell (Meteor create) runs fine then added a compatibility directory and inserted go-debug.js and it hangs building |
What are the entry point on the client and the server? |
Didn't define them simply created new project and dropped go into compatability directory |
Got this error recently. I emptied my meteor/local directory except the database and then reran meteor. Havent figured out how to fix it yet.
Was wondering if something changed with the beta release that broke it. Or was it just me? |
Hmm. So the entry point is effectively deduced? @JeremyBYU I also get an error just doing |
@pward123: Yep, i do that too (just with Scss instead of Stylus). Not sure if it's the right or "clean" way either, for me it just feels as if i am trying to fool some "meteor magic" there… 😕 |
@pward123 and @helb: That's a pretty hacky and coupled way to set up your styles for your project. I use SCSS but you can do this with any CSS preprocessor. I created a styles package and set up all of my variables and mixins in that package. Then in each of my UI packages, I import my styles package and import my mixins and variables as I need them. Each package then just adds it's own styles for it's own views and components. If I ever need to remove any packages / views, I simply remove the package and don't have to worry about touching multiple files or a main index file in order to do so. It's much looser coupling than what you guys are referring to and I think it works a lot better. |
@clayne11 have you managed to do some css modules with your workflow? |
I'm still on Meteor 1.2 as I'm running a pretty big production app so I'm not going to switch over to 1.3 until it's out of beta. I believe that CSS modules requires importing CSS files into your JS which you can't do with 1.2. I'm definitely interested in trying it out, it looks like a great paradigm, but it'll have to wait. |
@clayne11 unless I'm missing something, I don't believe css/scss/etc files located in node_modules will be automatically swept up and built into the bundle. So, to use your method, you'd have to continue using meteor packages with 1.3 |
I didn't realize you were referring to node modules. With Meteor 1.3 are you able to import your CSS into your JS files? If so that's definitely the better solution to go with. That way your CSS is tied directly to the component that requires it and when you import the component to render somewhere it will bring its CSS along with it. |
I'm assuming meteor 1.3 doesn't support css modules yet. I had no luck when I tried it a couple days ago. Sent from my iPad
|
@pward123 there is a project for css modules with 1.3 that I am using. It is still in beta but works well for basic cases (eg: you can't import vars with |
To everyone considering importing CSS, check out Importing CSS currently doesn't have a mechanism for cleanup, but with JSS, Plus, with JSS you can use plain JavaScript functions and variables for /#!/JoePea
|
And! Everything is namespaced, so you won't have name collisions. (This is off-topic now though. Let's open new issues when we can.) |
@markoshust I'm using a buildroot image (https://github.com/pward123/docker-tinymeteor/blob/release/v1.3.0/README.md) that's 14mb without any meteor app installed. My CI is setup to run meteor build, then it volume mounts the bundle into a node:0.10.41 container to perform the npm install. Once that's done, the result is docker built using the tiny image. edit: forgot to mention you can try the tiny image out using |
A new 1.3 beta which combines modules, mobile, and testing is now available: #6266 |
so should we close this issue and the cordova one and continue on 6266? |
Yes, let's close this! But I also think it would be better to have people open new issues from now on instead of commenting on a thread, because that makes it harder to keep track of whether some concern has been addressed. |
Hello, guys, could you please check this. I have app crushes after updating to |
I'm using Elemental UI with Meteor 1.3. beta 11. I had no problem in 1.2 and WebPack but when i try to import elemental.less i get: Uncaught Error: Cannot find module './../../../node_modules/elemental/less/elemental.less' same with css files i try to import. am i missing something? |
Hi, using react-autoform-material-ui with 1.3 beta 11 I get the following error. => Started proxy. TypeError: Arguments to path.join must be strings |
@clayne11 @pward123 I just wanted to remind everyone that importing CSS, Less, Sass, etc. from JS files is possible if you use Webpack with Meteor, plus you get a whole host of other benefits like automatic code splitting, and the ability to customize practically anything in the compilation process. |
I'm well aware. I will likely be switching my project to webpack because frankly the Meteor build system is just not keeping up at all. I can't deal with 20-30s code reloads when they could be 1-2s. It's costing me a lot of productivity. |
Along with these AMD changes, is there a way to tell the build system to ignore certain imports? For eg. I have
But something like such as |
@shawnmclean since let DevTools;
if (__DEV__) {
DevTools = require('redux-devtools').default; // .default necessary since Babel 6
} Or with Webpack 2 one can use let DevTools;
if (__DEV__) {
DevTools = System.import('redux-devtools');
} Also note that new webpack.DefinePlugin({
'Meteor.settings.public.environment': JSON.stringify('development')
}) |
@jedwards1211 note that |
We're starting the process towards Meteor 1.3, with module support, better NPM integration, better file load order configuration, and more.
Meteor 1.3 gives apps full ES6 (ES2015) modules support and better NPM support. Apps and packages can now load NPM modules that are installed via
npm install
on client and on server. Amongst other benefits, modules let you control file load order in much more precise way than naming your files in special ways.To get feedback early, we decided to go ahead and release a beta release that doesn't yet have all of the features ready, but does have almost complete support for modules.
Try the release by running
meteor update --release 1.3-modules-beta.8
in your app directory.@benjamn wrote a great document explaining how to use modules in Meteor.
Please start trying this release out! You can start experimenting with switching your apps or packages to use the new module features. Let us know what works well or doesn't.
Take a look at the list of changes in Meteor 1.3, and the remaining tasks.
The text was updated successfully, but these errors were encountered: