Meteor 1.3 *early beta* now available

@timfletcher That statement is essentially still valid with a new exception: files from node_modules won’t be loaded automatically, just as before, unless you explicitly load them with an import or require statement somewhere in your code. If you never import anything from node_modules, then those files will never load. However, if you have files outside of node_modules that you aren’t importing anywhere, then those files will be loaded automatically by Meteor unless they are inside any folder named imports.

I’m using various packages that are wrapping npm modules [1]
I’m seetnig errors like:

Uncaught ReferenceError: module is not defined
app.js:36 Uncaught TypeError: Cannot read property ‘Handsontable’ of undefined

here:

module.exports = exportModule(                                                                                     

this looks like node code for the original package to me.

I understand meteor now has a new way of requiring npm packages, but if the original npm package itself can’t find module… how do we work around that?

1 https://github.com/awsp/handsontable-meteor

OK so 1.3 seems to break wrapper packages, so I’m trying to debug how to use the new native meteor npm import features.

for others checking this thread, its important to do this:

mkdir node_modules

then

npm install whatever-package-you-want

and here are the docs:

so in my case I have added an npm package, but I am getting an error on trying to import it.

import Handsontable from 'handsontable';

Cannot find module ‘handsontable’

maybe that package itself is a bit funky as there was some discussion about npm support.

My question is - how do I figure out how to fix the import?

either the module identified by the main field of the package.json file, or index.js

The original module’s package.json has no main field and there is no index.js

So possibly that breaks meteor’s import feature?

@dcsan I might have had a similar issue: https://github.com/meteor/meteor/issues/5866

But yeah, if the package doesn’t have an index.js and no main entry, then you might need to import the main file (or multiple files) manually.

import something from 'handsontable/path/to/something'

It doesn’t seem meteor.com is working with 1.3-beta and NPM packages?

Example Here.

@benjamn How do we use NPM with Meteor packages? Do we just npm install whatever we need, then meteor publish will bundle the stuff in node_modules?

2 Likes

Are there any 1.3 boilerplates like the kickstarts for webpack?

2 Likes

+1.

I’m trying to work out whether I can npm install browserify or do I still have to use cosmos:browserify. Github issues https://github.com/meteor/meteor/issues/5795 and https://github.com/meteor/meteor/issues/5825 do not present any obvious answers.

EDIT: Actually, I just got it working without having to touch browserify at all… Not sure if I’m doing it right but that was the last step in my port to 1.3! Loving the speedy build although my app is still pretty small.

I wouldn’t call my project a boilerplate or even a clean project (after the multiple refactors in the last month) but at least it’s finally running on 1.3 with a bit of react/redux sprinkled on and I can move on to actually adding content! YAYAYA!!

If you have the redux chrome extension, you can see Tracker updating the store with meteor subscription data (on game creation) as it comes back to minimongo . This way, I keep all client state in the store, propagate any updates to components via props thus keeping them pure and easy to unit test.

We’re hopefully going to launch something like this with the Meteor Guide alongside 1.3.

I’d like to reiterate a question that was asked earlier - how will this work with importing the same NPM package in multiple Meteor packages? Will the dependency tree be managed to ensure only one copy of each library is included?

@clayne Great question, and thanks for reiterating it. My current plan (slightly different from what’s implemented in the latest beta release) is that the top-level node_modules/ directory in an app will provide importable packages not only for application code but also for Meteor packages. In other words, the app gets to decide which version of an npm package will be used throughout the app and its packages. Packages can still use Npm.depends to install their own local dependencies, but they can also import or require npm dependencies that they did not explicitly install, with the expectation that the application will provide those dependencies.

So, to answer your question: no, the dependency tree will not be managed by Meteor, and there will be no special enforcement of single installation, but it should be straightforward for the app to provide a single version of a common dependency.

This will work alright in the case of a package that I write myself, but what about if I want to release a package on Atmosphere?

Will there be a way to tell the compiler that a certain package is required as a top-level NPM package, or to have something like a weak Npm.depends such that if the if the NPM package is included at the top level, it doesn’t get included, otherwise it does?

@clayne I think these questions deserve their own forum thread, if you wouldn’t mind starting a new topic. I have some ideas, and I’m sure you do too, but I don’t want this discussion getting lost in the larger 1.3 announcement thread.

Yes, that would definitely cause problems. How does this package work without a main field or an index.js file?

Hey folks, as of today I’m getting back to work after some holiday downtime, and I’m hoping to spend this week responding to all the feedback and ideas above. Thanks for all the input, and for your patience!

This thread has gotten rather long, so if there’s something I don’t respond to in the next few days, don’t hesitate to resurface it. If it feels like a distinct topic, starting a new thread might be a good idea. Just @mention me and link back to the original post(s).

7 Likes

Yep, that’s the plan for 1.3: you have complete control over the contents of node_modules directories in your app, and Meteor will bundle those modules into your app when you deploy.

Future releases may introduce new features that help with managing npm dependencies, but we believe that can wait until after 1.3.

Ah, yes, that’s a bug: https://github.com/meteor/meteor/issues/5933

Created a new thread:

Cool stuff. Two package managers feels so dirty, but hopefully this will work out.

I don’t know what the deal is, but the imports/ directory thing is definitely not working for me. Maybe I’m just stupid. Tried /imports/, /server/imports/, /client/imports/, but files in those folders still get eager-loaded.

But I like this. It’s better than I expected. Well done.

Seems like this commit fixes it. Running Meteor from the latest checkout and now files in imports/ are not eagerly loaded :+1:

3 Likes