Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

component.js:1 Unexpected token import #1

Open
NikkiDreams opened this issue May 31, 2017 · 1 comment
Open

component.js:1 Unexpected token import #1

NikkiDreams opened this issue May 31, 2017 · 1 comment

Comments

@NikkiDreams
Copy link

Hi Nixx here at the MotherShip in PDX, Yes I live for pain running the latest of everything :-)
I have been using Marko-Starter for a little while now, good stuff. Now I am trying to ES2016 all my code. I added Marko-Starter-Babel and the suggested config.

I have a standalone Marko Component I'm building. When I run marko-starter server I get an error on the first line of the component. I had everything working before I started down the ES2016 updates in my project, so no ugly errors there. I am not sure if I am missing something or what. But it seems Babel is not transforming the component as expected. I've tried several different ways of Babelising the code without success.

Any thoughts, Ideas are very much appreciated.

[marko-starter plugins] Installed plugin: lasso
/../component.js:1
(function (exports, require, module, __filename, __dirname) { import update from 'immutability-helper';
SyntaxError: Unexpected token import

my dependencies included in package.json:

...
"lasso-babel-transform": "^1.0.1",
"lasso-less": "^2.4.3",
"lasso-marko": "^2.3.0",
"lasso-sass": "^2.0.0",
"lasso-tools": "^2.0.9",
"marko": "4.4.6",
"marko-devtools": "git://github.com/marko-js/marko-devtools#v1.0.6",
"marko-starter": "git://github.com/marko-js/marko-starter#v1.1.8",
"marko-starter-babel": "git://github.com/marko-js/marko-starter#v1.0.2",
...

project.js

const markoStarter = require('marko-starter');
markoStarter.plugins(['marko-starter-babel']);
const lassoConf = require('./config/lasso.json');
const paypalPaymentsApi = require('./lib/paypalExpressCheckoutService');
const indexTemplate = require('marko').load(require.resolve('./test/test-page/index.marko'));

module.exports = require('marko-starter').projectConfig({
    routePathPrefix: '/',
    lassoConfig: lassoConf,
    plugins: ['marko-starter-babel'],
    routes: [
        {
            route: {
                path: '/',
                metadata: {},
                params: {},
                handler: (req, res) => {
                    indexTemplate.render({
                        componentName: 'My Component'
                    },
                    function(err, html) {
                        console.log(`Template output: ${html}`);
                        if(err){
                            console.log(`ERROR: ${err}`);
                        }
                    });
                }
            }
        }, {
            route: {
                path: '/foo',
                metadata: {},
                params: {},
                handler: (req, res) => res
            }
        }
    ]
});

lasso.json

{
    "flags": ["OTD"],
    "bundlingEnabled": true,
    "minify": false,
    "cacheProfile": "development",
    "resolveCssUrls": true,
    "fingerprintsEnabled": true,
    "includeSlotNames": true,
    "noConflict": "OTD",
    "outputDir": "./static",
    "bundles": [
       {
           "name": "jquery",
           "dependencies": [
               "require: jquery"
           ]
       }
   ],
    "plugins": [
        "lasso-marko",
        {
            "plugin": "lasso-sass",
            "config": {
                "extensions": ["scss", "sass", "css"]
            }
        },
        {
            "plugin": "lasso-less",
            "config": {
                "extensions": [
                    "less", "css"
                ],
                "lessConfig": {
                    "strictMath": true,
                    "strictUnits": true
                }
            }
        }
    ],
    "require": {
        "transforms": [
            {
                "transform": "lasso-babel-transform",
                "config": {
                    "extensions": [".js"],
                    "babelOptions": {
                        "presets": [ "latest" ]
                    }
                }
            }
        ]
    }
}

@ironsweet
Copy link

I hit the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants