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

aurelia-validation is not an ES module #417

Closed
MaximBalaganskiy opened this issue Feb 20, 2017 · 8 comments
Closed

aurelia-validation is not an ES module #417

MaximBalaganskiy opened this issue Feb 20, 2017 · 8 comments
Assignees

Comments

@MaximBalaganskiy
Copy link

MaximBalaganskiy commented Feb 20, 2017

I'm submitting a feature request

  • Library Version:
    1.0.0-beta.1.0.0

  • Operating System:
    Windows 10

  • Node Version:
    6.4.0

  • NPM Version:
    3.10.3

  • JSPM OR Webpack AND Version
    JSPM 0.17.0-beta.40

  • Browser:
    all

  • Language:
    TypeScript 2.0

Current behavior:
import { ValidationRules } from "aurelia-validation"; imports undefined value

Expected/desired behavior:
import { ValidationRules } from "aurelia-validation"; imports a class

This forces developers using a different import syntax

import av from "aurelia-validation";
var ValidationRules = av.ValidationRules;
@jdanyow
Copy link
Contributor

jdanyow commented Feb 20, 2017

If you add exports.__esModule = true to the file is the issue resolved?

It's dist/commonjs/aurelia-validation.js right?

@MaximBalaganskiy
Copy link
Author

Not sure if that will be enough... It would also need exports.ValidationRule = blah; assignment.
Yes, it's in the aurelia-validation file

@MaximBalaganskiy
Copy link
Author

I can try tomorrow. End of day here

@jdanyow
Copy link
Contributor

jdanyow commented Feb 20, 2017

sounds good- let me know what you find

@MaximBalaganskiy
Copy link
Author

Confirmed, just adding the following code solves the issue

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

Is it something added manually or by turning some flag in the build script?

@jdanyow
Copy link
Contributor

jdanyow commented Feb 21, 2017

Could you try one other thing? Remove the exports.__esModule property you just added and in your SystemJS config, add:

meta: {
  'aurelia-validation': { esModule: true, format: 'cjs' },  // (or format: 'amd' depending on which one you're loading)
}

@MaximBalaganskiy
Copy link
Author

MaximBalaganskiy commented Feb 21, 2017 via email

@jdanyow
Copy link
Contributor

jdanyow commented Feb 21, 2017

maybe one of these will do the trick:

        map: {
          'aurelia-validation': 'node_modules/aurelia-validation/dist/amd',
        },
        meta: {
          'aurelia-validation': { esModule: true, format: 'amd' },
        },
        packages: {
          'aurelia-validation': { main: 'aurelia-validation.js' },
        }
        map: {
          'aurelia-validation': 'node_modules/aurelia-validation/dist/amd',
        },
        packages: {
          'aurelia-validation': { main: 'aurelia-validation.js', meta: { esModule: true, format: 'amd' } },
        }

I'm still researching the best way to add the exports.__esModule = true to the typescript output.

jdanyow added a commit that referenced this issue Feb 23, 2017
Fixes __esModule issue (fixes #417)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants