jspm / jspm-cli

ES Module Package Manager
https://jspm.org
Apache License 2.0
3.78k stars 272 forks source link

config problem "jspm_packages" and "node_modules" use different path #1635

Closed shaoahs closed 8 years ago

shaoahs commented 8 years ago

os: linux mageia 5 nodejs : 4.4.0 jspm : 0.16.x and 0.17beta

if "jspm_packages" and "node_modules" are in the project root directory, the js source code don't add '.js' on the import file name, but if "jspm_packages" is not in the root directory, the import file need to add ".js".

Case1 : in the root directory:

jspm bundle dir/main Can use "import 'name';"

Case 2: "jspm_packages" is not in the root directory.

jspm bundle dir/main source code can not use "import 'name';"
But it can use as below: jspm bundle dir/main.js need to use "import 'name.js'; "

Why case 2 can not auto parse ".js" file ?

guybedford commented 8 years ago

js extensions are optional for packages via the SystemJS configuration defaultExtension. For all other requires extensions are required. This is because if you do import 'https://cdn.com/file' we can't assume if you do or do not want to add a .js extension, so will not do it by default unless it is an explicitly defined package through package configuration.