user3787896
user3787896

Reputation:

Adding libraries in Aurelia project

I created a new project with the Aurelia cli but when I want to import a personnal library, the consol return an Unexpected token error.

I followed the Adding Client Libraries to Your Project Tutorial.

This is my library code :

export function hello{
    console.log("hello");
}

And in the aurelia.json file I added a new entry :

  {
    "name": "hello",
    "path": "../scripts/hello"
  },  

I think this is a configuration problem in the transpiler entry, but i didn't find any informations.

  "transpiler": {
    "id": "babel",
    "displayName": "Babel",
    "fileExtension": ".js",
    "options": {
      "plugins": [
        "transform-es2015-modules-amd"
      ]
    },
    "source": "src/**/*.js"
  }, 

Upvotes: 1

Views: 839

Answers (1)

Marton Sagi
Marton Sagi

Reputation: 1257

In my opinion, bundles.dependencies section of aurelia.json should be used for external libraries already transpilled to ES5 format.

  1. Your could move your internal ES6 "library" into src/ folder, so it would be transpilled along with the rest of your source code.
  2. In case you want to create a shared library, you'll need a separate project for that, which provides an ES5 output.

In the latter case, Aurelia Skeleton Plugin may give you fresh ideas. It is configured to provide multiple output formats.

Upvotes: 1

Related Questions