question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AMD module support

See original GitHub issue

Hi.

I kinda cannot get your package to work, maybe you can help me.

When I do

var Lang = require('lang.js')

var lang = new Lang({
    messages: {
        "en.foo": {
            bar: 'baz'
        },
        "pl.foo": {
            bar: 'quz'
        }
    },
    locale: 'pl',
    fallback: 'en'
})

I get an error saying

Uncaught TypeError: Lang is not a constructor

Same thing happens when I replace require with import:

import Lang from 'lang.js';

After import/require the Lang object looks like this:

{
    locale: "en", 
    fallback: undefined, 
    messages: undefined
}

Setup

Dependencies

{
    "gulp": "^3.9.1",
    "gulp-shell": "^0.5.2",
    "jquery": "^3.1.0",
    "lang.js": "^1.1.1",
    "laravel-echo": "^1.1.0",
    "laravel-elixir": "^6.0.0-11",
    "laravel-elixir-vue-2": "^0.2.0",
    "laravel-elixir-webpack-official": "^1.0.2",
    // and other like Vue or Moment.js    
}

gulpfile.js

const elixir = require('laravel-elixir');
const shell = require('gulp-shell');

require('laravel-elixir-vue-2');

var Task = elixir.Task;
elixir.extend('langjs', function(path) {
    new Task('langjs', function() {
        gulp.src('').pipe(shell('php artisan lang:js resources/assets/js/messages.js'));
    });
});

elixir(mix => {
    mix.sass('app.scss')
        .langjs()
        .webpack('app.js')

});

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rmariuzzocommented, Oct 18, 2016

@KKSzymanowski thank you for validate.

@jartaud can you try with 1.1.3 and give us more details.

1reaction
KKSzymanowskicommented, Oct 18, 2016

@jartaud Didn’t work for me yesterday,because npm downloaded 1.1.2. Today I forced 1.1.3 and it works. Edit: you can check which version is installed by npm ls lang.js.

Thank you @rmariuzzo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why AMD? - RequireJS
This page talks about the design forces and use of the Asynchronous Module Definition (AMD) API for JavaScript modules, the module API supported...
Read more >
Asynchronous module definition - Wikipedia
Asynchronous module definition (AMD) is a specification for the programming language JavaScript. It defines an application programming interface (API) that ...
Read more >
Introduction to AMD Modules - Dojo Toolkit Tutorial
Dojo supports modules written in the Asynchronous Module Definition (AMD) format ... In this tutorial, we explain the basics of understanding and using...
Read more >
What are AMD modules? Fetch your sick bag - Jim Fisher
ECMAScript modules are not acceptable because they don't have wide enough support yet. So, enter Asynchronous Module Definition, or AMD.
Read more >
Writing Modular JavaScript With AMD, CommonJS & ES ...
Learn how to write modular JavaScript using modern synchronous and asynchronous formats such as AMD and CommonJS.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found