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

Importing server-side module error #21

Open
nkg448 opened this issue Nov 1, 2018 · 3 comments
Open

Importing server-side module error #21

nkg448 opened this issue Nov 1, 2018 · 3 comments

Comments

@nkg448
Copy link

nkg448 commented Nov 1, 2018

When I try doing

let beaverLogger = require('beaver-logger/server');

In my app js file, I get the following import error on start:

(function (exports, require, module, __filename, __dirname) { export * from './server';

SyntaxError: Unexpected token import

I've tried adding Babel 7 to my project, tried various babel config settings to support babel transpilation of imported modules, no luck. My app is fairly simple, so there shouldn't be any weird left-field issues. I'm using Node 8.12 I believe, [email protected]. Any ideas?

@bugzpodder
Copy link

I recommend downgrading to 3.0.17 as i think it was with better functionalities. (not sure what happened to transitions). I am personally going to do that.

I got 4.0.5 to work by using webpack + babel:

const nodeExternals = require("webpack-node-externals");

module.exports = {
  target: "node",
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: require.resolve("babel-loader"),
        },
      },
    ],
  },
  externals: [
    nodeExternals({
      modulesFromFile: true,
      whitelist: [/^beaver-logger\//],
    }),
  ],
};
module.exports = {
  presets: [
    [
      require("@babel/preset-env"),
      {
        targets: {
          node: "current",
        },
      },
    ],
  ],
};

@bluepnume
Copy link
Collaborator

Yikes looks like Babel isn't transforming those imports. I'll push a fix this afternoon. Thanks for the heads up!

@bluepnume
Copy link
Collaborator

bluepnume commented Nov 4, 2018

Should be fixed now. Can you please test once more?

(not sure what happened to transitions)

beaver-logger v4 has been stripped back to focus on the thing it does well: batching and dispatching events from the browser to the server.

If you'd like to use transitions on your app, please feel free to borrow the code from v3: https://github.com/krakenjs/beaver-logger/blob/a281c8f69863d78c5aff0f5104d69041ec388c93/client/transitions.js -- it should work pretty well outside of the core beaver-logger module. Or if you'd like to expose this as a separate optional module I'd be more than happy for you to use the above code as a starting point. :)

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

3 participants