marko-js-archive / marko-starter-babel

MIT License
1 stars 1 forks source link

component.js:1 Unexpected token import #1

Open NikkiDreams opened 7 years ago

NikkiDreams commented 7 years ago

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 commented 7 years ago

I hit the same issue.