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.
javascript ecmascript-6
add a comment |
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.
javascript ecmascript-6
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
add a comment |
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.
javascript ecmascript-6
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
javascript ecmascript-6
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
add a comment |
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
add a comment |
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.
Depends on the module loader that you are using. It might indeed resolvemoduleone
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
add a comment |
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.
Depends on the module loader that you are using. It might indeed resolvemoduleone
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
add a comment |
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.
Depends on the module loader that you are using. It might indeed resolvemoduleone
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
add a comment |
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.
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.
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 resolvemoduleone
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
add a comment |
Depends on the module loader that you are using. It might indeed resolvemoduleone
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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