Open stefanpenner opened 10 years ago
Is there plans to support anonymous?
No, the main issue is that formatters do not have access to the cli options, which means there is no way to specify whether or not we want anonymous modules to be generated, obviously that could change in the transpiler. /cc @eventualbuddha
https://github.com/square/es6-module-transpiler/blob/master/lib/cli/convert.js#L90
@caridy so plans do exist but we are just blocked by es6-module-transpiler?
correct.
Understood. Thanks for the clarification :)
Hi @caridy and @stefanpenner ;) I was just about to write an experimental cli addon using module syntax and came upon your compiler. Would be cool with an editor plugin for Atom to make it easier to use. Have been wanting to experiment with that lately. What do you think?
Oh, well... just discovered Webstorm 8 already has some es6 support baked in
https://www.youtube.com/watch?v=jbfkcmxLLKY
Another thought would be for ember-cli to auto-detect that it is such a module/format and then "do its magic" using this compiler, before including the script?
I tried a small experiment:
bower_components/ember-validations/index.js
import Ember from '../ember/ember';
Ember.Validations = Ember.Namespace.create({
VERSION: '1.0.0',
name: 'validations'
});
console.log('hello from Ember.Validations');
export default Ember.Validations;
When I compile it from Webstorm it tries to resolve the import and I'm told:
/Users/kristianmandrup/experiments/bower_components/ember-validations/index:1:8: 'default' is not exported by '../../../bower_components/ember/ember'
So I guess this is one major reason why it makes better sense to pack it up as an AMD to be evaluated later...
@kristianmandrup it is just telling you that '../ember/ember'
doesn't have a default export, and it probably doesn't or it is not an es6 module.
yes, I understand that ;) I removed the es6 syntax and it worked just fine without it.
If you want to process the modules by the RequireJS optimizer (r.js
) and let it assign the module names depending on its functionality (packages, bundles), you will want to disable generation of module names nu es6-module-transpiler
. I added an API to suppress the named modules in #8.
Command line:
AMDFORMATTER_NAMED_MODULES=false ./node_modules/.bin/compile-modules ...
Library:
var container = new Container({
resolvers: [new FileResolver(['lib/'])],
formatter: new AMDFormatter({ namedModules: false })
});
Such modules can be mixed with hand-written AMD.JS modules in a single project and bundled together.
@stefanpenner can you elaborate more? the current implement does not support anonymous modules, it relies on the names computed by es6-module-transpiler