spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.98k stars 183 forks source link

spacetime.mjs doesn't seem to work with uglifyjs #172

Closed johnfumaster closed 4 years ago

johnfumaster commented 4 years ago

I'm currently importing spacetime like so. import spacetime from 'spacetime;

Everything works fine, but once it goes to build, it errors out with this error.

ERROR in static/js/npm.spacetime.125.e5ac8bb05e6de4e0c6fb.js from UglifyJs
Unexpected token: operator «>» [./node_modules/spacetime/builds/spacetime.mjs:11,0][static/js/npm.spacetime.125.e5ac8bb05e6de4e0c6fb.js:17,27]
 
 Build failed with errors.

I'm not sure what could have caused this, nor could I find any solutions online.

Currently, in order to get my project to build, I have to import from the build directory. So it's got something to do with the .mjs

spencermountain commented 4 years ago

hey @johnfumaster mjs creates es6 javascript, which uses the ()=> function syntax. If you want to use uglify on that, you'll have to run it through babel. cheers

johnfumaster commented 4 years ago

@spencermountain but I am using babel. The rest of my project is using () =>

Here is my module settings from webpack related to babel

{
        test: /\.m?js$/,
        loader: "babel-loader",
        include: [
          resolve("src"),
          resolve("test"),
          resolve("node_modules/webpack-dev-server/client")
        ],
        exclude: [/node_modules/, resolve('src/lang')],
        options: {
          plugins: ['lodash'],
          presets: [['@babel/env']]
        }
      },