Module version when importing ES2015 module











up vote
0
down vote

favorite












Let's suppose I have two ES2015 modules in the same folder:



//moduleone-1.5.0.js
export function temp() {
console.log("Hi");
}

//moduletwo-2.0.0.js
import {temp} from './moduleone';//LINE X
temp();


Should I use './moduleone' or './moduleone-1.5.0' at LINE X? I need to understand how it must work according to specs.










share|improve this question
























  • Have you tried both?
    – Jonas Wilms
    Nov 11 at 18:08










  • @JonasWilms in node.js only './moduleone-1.5.0' works
    – Pavel_K
    Nov 11 at 18:09








  • 3




    npm has nothing to do with ES6 modules.
    – SLaks
    Nov 11 at 18:11






  • 2




    The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
    – Felix Kling
    Nov 11 at 18:11

















up vote
0
down vote

favorite












Let's suppose I have two ES2015 modules in the same folder:



//moduleone-1.5.0.js
export function temp() {
console.log("Hi");
}

//moduletwo-2.0.0.js
import {temp} from './moduleone';//LINE X
temp();


Should I use './moduleone' or './moduleone-1.5.0' at LINE X? I need to understand how it must work according to specs.










share|improve this question
























  • Have you tried both?
    – Jonas Wilms
    Nov 11 at 18:08










  • @JonasWilms in node.js only './moduleone-1.5.0' works
    – Pavel_K
    Nov 11 at 18:09








  • 3




    npm has nothing to do with ES6 modules.
    – SLaks
    Nov 11 at 18:11






  • 2




    The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
    – Felix Kling
    Nov 11 at 18:11















up vote
0
down vote

favorite









up vote
0
down vote

favorite











Let's suppose I have two ES2015 modules in the same folder:



//moduleone-1.5.0.js
export function temp() {
console.log("Hi");
}

//moduletwo-2.0.0.js
import {temp} from './moduleone';//LINE X
temp();


Should I use './moduleone' or './moduleone-1.5.0' at LINE X? I need to understand how it must work according to specs.










share|improve this question















Let's suppose I have two ES2015 modules in the same folder:



//moduleone-1.5.0.js
export function temp() {
console.log("Hi");
}

//moduletwo-2.0.0.js
import {temp} from './moduleone';//LINE X
temp();


Should I use './moduleone' or './moduleone-1.5.0' at LINE X? I need to understand how it must work according to specs.







javascript ecmascript-6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 18:22

























asked Nov 11 at 18:06









Pavel_K

2,70341769




2,70341769












  • Have you tried both?
    – Jonas Wilms
    Nov 11 at 18:08










  • @JonasWilms in node.js only './moduleone-1.5.0' works
    – Pavel_K
    Nov 11 at 18:09








  • 3




    npm has nothing to do with ES6 modules.
    – SLaks
    Nov 11 at 18:11






  • 2




    The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
    – Felix Kling
    Nov 11 at 18:11




















  • Have you tried both?
    – Jonas Wilms
    Nov 11 at 18:08










  • @JonasWilms in node.js only './moduleone-1.5.0' works
    – Pavel_K
    Nov 11 at 18:09








  • 3




    npm has nothing to do with ES6 modules.
    – SLaks
    Nov 11 at 18:11






  • 2




    The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
    – Felix Kling
    Nov 11 at 18:11


















Have you tried both?
– Jonas Wilms
Nov 11 at 18:08




Have you tried both?
– Jonas Wilms
Nov 11 at 18:08












@JonasWilms in node.js only './moduleone-1.5.0' works
– Pavel_K
Nov 11 at 18:09






@JonasWilms in node.js only './moduleone-1.5.0' works
– Pavel_K
Nov 11 at 18:09






3




3




npm has nothing to do with ES6 modules.
– SLaks
Nov 11 at 18:11




npm has nothing to do with ES6 modules.
– SLaks
Nov 11 at 18:11




2




2




The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
– Felix Kling
Nov 11 at 18:11






The specification does not impose any rules on the module identifier and how it is resolved. How that works depends on the module loader which is not part of the spec.
– Felix Kling
Nov 11 at 18:11














1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










There is no "module version". You got two different modules, one named moduleone-1.5.0 and one named moduletwo-2.0.0, those are the names you have to use for importing.



As you said you are using NodeJS (npm), you should actually install those modules by adding it to the package.json:



 { 
"dependencies" : {
"moduleone" : "1.5.0"
}
}


then you can import from "moduleone"; and change the versions in the package spec as needed.






share|improve this answer























  • Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
    – Bergi
    Nov 11 at 18:13






  • 1




    @bergi all the ones I know don't do that
    – Jonas Wilms
    Nov 11 at 18:15










  • But how will browsers work?
    – Pavel_K
    Nov 11 at 18:18










  • @pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
    – Jonas Wilms
    Nov 11 at 18:20






  • 1




    @Pavel_K: Browsers likely treat module identifiers as file paths.
    – Felix Kling
    Nov 12 at 17:00











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251664%2fmodule-version-when-importing-es2015-module%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










There is no "module version". You got two different modules, one named moduleone-1.5.0 and one named moduletwo-2.0.0, those are the names you have to use for importing.



As you said you are using NodeJS (npm), you should actually install those modules by adding it to the package.json:



 { 
"dependencies" : {
"moduleone" : "1.5.0"
}
}


then you can import from "moduleone"; and change the versions in the package spec as needed.






share|improve this answer























  • Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
    – Bergi
    Nov 11 at 18:13






  • 1




    @bergi all the ones I know don't do that
    – Jonas Wilms
    Nov 11 at 18:15










  • But how will browsers work?
    – Pavel_K
    Nov 11 at 18:18










  • @pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
    – Jonas Wilms
    Nov 11 at 18:20






  • 1




    @Pavel_K: Browsers likely treat module identifiers as file paths.
    – Felix Kling
    Nov 12 at 17:00















up vote
1
down vote



accepted










There is no "module version". You got two different modules, one named moduleone-1.5.0 and one named moduletwo-2.0.0, those are the names you have to use for importing.



As you said you are using NodeJS (npm), you should actually install those modules by adding it to the package.json:



 { 
"dependencies" : {
"moduleone" : "1.5.0"
}
}


then you can import from "moduleone"; and change the versions in the package spec as needed.






share|improve this answer























  • Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
    – Bergi
    Nov 11 at 18:13






  • 1




    @bergi all the ones I know don't do that
    – Jonas Wilms
    Nov 11 at 18:15










  • But how will browsers work?
    – Pavel_K
    Nov 11 at 18:18










  • @pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
    – Jonas Wilms
    Nov 11 at 18:20






  • 1




    @Pavel_K: Browsers likely treat module identifiers as file paths.
    – Felix Kling
    Nov 12 at 17:00













up vote
1
down vote



accepted







up vote
1
down vote



accepted






There is no "module version". You got two different modules, one named moduleone-1.5.0 and one named moduletwo-2.0.0, those are the names you have to use for importing.



As you said you are using NodeJS (npm), you should actually install those modules by adding it to the package.json:



 { 
"dependencies" : {
"moduleone" : "1.5.0"
}
}


then you can import from "moduleone"; and change the versions in the package spec as needed.






share|improve this answer














There is no "module version". You got two different modules, one named moduleone-1.5.0 and one named moduletwo-2.0.0, those are the names you have to use for importing.



As you said you are using NodeJS (npm), you should actually install those modules by adding it to the package.json:



 { 
"dependencies" : {
"moduleone" : "1.5.0"
}
}


then you can import from "moduleone"; and change the versions in the package spec as needed.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 18:15

























answered Nov 11 at 18:12









Jonas Wilms

53.4k42547




53.4k42547












  • Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
    – Bergi
    Nov 11 at 18:13






  • 1




    @bergi all the ones I know don't do that
    – Jonas Wilms
    Nov 11 at 18:15










  • But how will browsers work?
    – Pavel_K
    Nov 11 at 18:18










  • @pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
    – Jonas Wilms
    Nov 11 at 18:20






  • 1




    @Pavel_K: Browsers likely treat module identifiers as file paths.
    – Felix Kling
    Nov 12 at 17:00


















  • Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
    – Bergi
    Nov 11 at 18:13






  • 1




    @bergi all the ones I know don't do that
    – Jonas Wilms
    Nov 11 at 18:15










  • But how will browsers work?
    – Pavel_K
    Nov 11 at 18:18










  • @pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
    – Jonas Wilms
    Nov 11 at 18:20






  • 1




    @Pavel_K: Browsers likely treat module identifiers as file paths.
    – Felix Kling
    Nov 12 at 17:00
















Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
– Bergi
Nov 11 at 18:13




Depends on the module loader that you are using. It might indeed resolve moduleone to the current version of that module.
– Bergi
Nov 11 at 18:13




1




1




@bergi all the ones I know don't do that
– Jonas Wilms
Nov 11 at 18:15




@bergi all the ones I know don't do that
– Jonas Wilms
Nov 11 at 18:15












But how will browsers work?
– Pavel_K
Nov 11 at 18:18




But how will browsers work?
– Pavel_K
Nov 11 at 18:18












@pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
– Jonas Wilms
Nov 11 at 18:20




@pavel_k the browser support is still not good, and in most cases I'd recommend bundling all modules to one js file to be served to the client.
– Jonas Wilms
Nov 11 at 18:20




1




1




@Pavel_K: Browsers likely treat module identifiers as file paths.
– Felix Kling
Nov 12 at 17:00




@Pavel_K: Browsers likely treat module identifiers as file paths.
– Felix Kling
Nov 12 at 17:00


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53251664%2fmodule-version-when-importing-es2015-module%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python