GithubHelp home page GithubHelp logo

Comments (6)

krisselden avatar krisselden commented on June 2, 2024 1

You can also add a paths to your tsconfig to specify a mapping to a different location.

"paths": { "npm:ts-mockito" : ["./node_modules/ts-mockito"] }

from ember-cli-typescript.

chriskrycho avatar chriskrycho commented on June 2, 2024 1

Yes! I ran into that solution earlier today and was just coming here to suggest it. That’s the solution I’ll be recommending going forward.

from ember-cli-typescript.

wooandoo avatar wooandoo commented on June 2, 2024

I found a solution without browserify, but I prefer a solution with browserify (to avoid the next shims) ;-) :

npm install --save @types/ramda
ember install ember-cli-import-from-npm

in ember-cli-build.js:

app.import(app.nodeModulesDirectory + '/ramda/dist/ramda.js');
app.import('vendor/shims/ramda.js');

and in vendor/shims/ramda.js:

(function() {
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

  function vendorModule() {
    'use strict';
    return _extends({}, { 'default': R}, R);
  }

  define('ramda', [], vendorModule);
})();

an idea?

from ember-cli-typescript.

chriskrycho avatar chriskrycho commented on June 2, 2024

@wooandoo just wanted you to know as I'm picking up steam on working on this that I've seen this. I'm not yet sure what the answer here will be, and it'll be a bit before I have time to look at it, but it's on my radar and I will get back to it!

from ember-cli-typescript.

wooandoo avatar wooandoo commented on June 2, 2024

hello,
have you an alternative to load NPM modules from typescript file (without browerify?)
how can I help?

Frédéric

from ember-cli-typescript.

chriskrycho avatar chriskrycho commented on June 2, 2024

You can use ember-browserify with a small shim. For example (drawing on the notes I wrote up for #78), you could import the ts-mockito module using ember-browserify in parallel with TypeScript by creating a TypeScript shim module named npm:ts-mockito which simply imports and re-exports the ts-mockito exports. Something like this should work (I haven’t tested it, though!):

declare module 'npm:ts-mockito' {
  import mockito from 'ts-mockito';
  export default mockito;
}

from ember-cli-typescript.

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.