Coder Social home page Coder Social logo

Comments (11)

grigio avatar grigio commented on September 24, 2024

./met add aPackage
And you have it globally exposed

from meteor-webpack-react.

vjau avatar vjau commented on September 24, 2024

Thank you, but i guess there is no way atm to require it (like universe:modules does), to make the typescript compiler happy ?

from meteor-webpack-react.

grigio avatar grigio commented on September 24, 2024

There is a bug open about typescript, basically you import or require npm modules where you need or you install packages a la Meteor way and you use the function globally exposed

from meteor-webpack-react.

vjau avatar vjau commented on September 24, 2024

Ok, thanks.

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 24, 2024

@vjau as far as making the typescript compiler happy... could you have a file called packages.js and then do something like this?

// packages.js
export const Meteor = Meteor;
export const SimpleSchema = SimpleSchema;
export const FlowRouter = FlowRouter;


// somewhere else

import FlowRouter from '../../packages/FlowRouter';
// or with an alias
import FlowRouter from 'packages/FlowRouter';

from meteor-webpack-react.

vjau avatar vjau commented on September 24, 2024

@AdamBrodzinski : actually, the idiomatic way to do that in Typescript when the variables are global and comes from a js (= not TS) file, is to use some "ambient" declarations in a d.ts file.
The question about "requiring" the meteor packages was more about the better scope control this would have given over "everything in global" import.
However i guess we will have to wait for MDG to provide a proper solution, hoping they will make the most compatible (not too meteorish...) choice.
I wonder if it would be doable to write a meteor package loader for webpack, that would somehow transpile (build) the files in the package in a single ES6 module that would have the correct exports.

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 24, 2024

@vjau ah I see! thanks for clearing that up!

I wonder if it would be doable to write a meteor package loader for webpack, that would somehow transpile (build) the files in the package in a single ES6 module that would have the correct exports.

Perhaps but since MDG will do this eventually it's easier to just leave them global and use a few packages as possible and require NPM modules when available (like Moment or Ramda, etc..)

Have you had a look at the typescript PR yet? Have you been able to get hot loading to work with TS? This PR adds support for manual compiling and the 2nd commit includes a loader but no hot loading:
#43

from meteor-webpack-react.

vjau avatar vjau commented on September 24, 2024

Actually, my tsx files are transpiled by Atom to jsx, i don't use the webback typescript loader.
Sometimes i have to reload the page so that it updates correctly, but i don't think this is typescript related, since for all webbpack knows, it's a regular jsx project.

from meteor-webpack-react.

AdamBrodzinski avatar AdamBrodzinski commented on September 24, 2024

Ah gotcha. That's how the the PR author did it as well... built to dist/ and required the js from dist.

Off topic but have you used Facebook's Flow yet? It looks interesting and I was thinking about using it since it's fairly easy to integrate into current projects.

from meteor-webpack-react.

vjau avatar vjau commented on September 24, 2024

I have tried flow, but i gave up since it doesn't support source files with unicode and won't for sometime.
Also webstorm doesn't support it atm and should not support it either in next version. It's still pretty experimental.
I think atm that Typescript has a stronger momentum.
Eventually, i guess (hope) we will have type support in ES8, and that we won't need those sideprojects anymore.

from meteor-webpack-react.

jedwards1211 avatar jedwards1211 commented on September 24, 2024

My goal for this project isn't to provide a require alternative for using meteor packages...just to be able to use it in my own code and avoid the meteor ecosystem as much as possible. If you want to use Meteor packages with this, best use them the Meteor way. I don't have time to experiment with doing anything like rocket:module or universe:modules does, but I'd be happy to accept PRs!

from meteor-webpack-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.