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

ES5 should be the default "main" in package.json #29

Closed
imgx64 opened this issue Oct 24, 2016 · 2 comments
Closed

ES5 should be the default "main" in package.json #29

imgx64 opened this issue Oct 24, 2016 · 2 comments

Comments

@imgx64
Copy link

imgx64 commented Oct 24, 2016

package.json has the following:

  "main": "es2015/index.js",
  "module": "es2015/index.js",

I think this should be "main": "es5/index.js". Currently es2015 module is used by default if you import @ionic/storage, which breaks non-module-aware tools like browserify. I use browserify for karma tests, and this is breaking it. Even babelify doesn't work because @ionic/storage/es2015/index.js is in node_modules/ and babelify won't touch it unless I set global: true,, which produces a lot of unrelated errors.

This is the error I get when I run karma with browserify:

> karma start  --no-auto-watch --single-run

24 10 2016 09:46:50.363:ERROR [framework.browserify]: bundle error
24 10 2016 09:46:50.366:ERROR [framework.browserify]:
redacted/ionic-app/node_modules/@ionic/storage/es2015/index.js:1
import { Storage } from './storage';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

karma.conf.js:

module.exports = function(config) {
  config.set({
    basePath: '',

    files: [
      'node_modules/ionic-angular/polyfills/polyfills.js',
      'node_modules/jasmine-promises/dist/jasmine-promises.js',
      'src/**/*.spec.ts'
    ],

    exclude: [],

    frameworks: ['jasmine', 'browserify'],

    preprocessors: {
      '**/*.ts': ['browserify']
    },

    reporters: ['progress'],

    logLevel: config.LOG_INFO,

    browsers: ['PhantomJS'],

    browserify: {
      debug: true,
      extensions: ['.ts'],
      configure: function(bundle) {
        bundle.once('prebundle', function() {
          bundle
            .plugin('tsify')
            .transform('babelify', {
              // global: true,
              // ignore: /\/node_modules\/(?!@ionic\/storage)/,
              extensions: ['.js', '.ts'],
              presets: ['es2015']
            })
        });
      }
    }
  });
};

I tried to import @ionic/storage/es5 instead of @ionic/storage, but I hit issue #18 and couldn't proceed.

@RobertoDebarba
Copy link

Same here. I hope that wil be solven soon, because I can't find a way to run my tests with karma.

@mhartington
Copy link
Contributor

Should be good with 2.2.0

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