less.js icon indicating copy to clipboard operation
less.js copied to clipboard

chore: use explicit path

Open jimmywarting opened this issue 3 years ago • 8 comments

What:

I changed some imports to be explicit (regarding ESM rules) Remote sources can't just guess what file you meant to import... things such as index.js is bad...

Why:

File extension is mandatory

How:

my vscode settings automatically trims whitespace, so those got included as well...

Checklist:

  • [ ] Documentation
  • [ ] Added/updated unit tests
  • [ ] Code complete

there are a few places left... but thought i do little by little

jimmywarting avatar Apr 15 '22 17:04 jimmywarting

I'm confused about this. I don't see a Github issue or anything that provides context as to why this is necessary other than developer preference.

matthew-dean avatar Apr 16 '22 18:04 matthew-dean

I for instances would like to be able to use the original code rather than some down leveled compiled version also, some places where already using .js

jimmywarting avatar Apr 16 '22 18:04 jimmywarting

From node's docs:

Mandatory file extensions# A file extension must be provided when using the import keyword to resolve relative or absolute specifiers. Directory indexes (e.g. './startup/index.js') must also be fully specified.

This behavior matches how import behaves in browser environments, assuming a typically configured server.

so, no... it's not just a "developer preference".

jimmywarting avatar Apr 16 '22 19:04 jimmywarting

The source code right now is meant to be transpiled. Although I think it would be great if we moved back to a non-transpiled model, based on current supported Node versions. (The problem in the past is that there were breaking changes for downstream dependents that expected functions / function prototypes vs. classes.)

But in the short term, I would be hesitant to make this change without some kind of exploration of side-effects.

matthew-dean avatar Apr 21 '22 20:04 matthew-dean

can this be merged? or would you rather have wanted me to send smaller changes / PR's?

jimmywarting avatar Jan 14 '23 15:01 jimmywarting

No, I don't see how this can be merged as there are no tests proving this doesn't break in any Node environment when imported directly.

matthew-dean avatar Jan 15 '23 00:01 matthew-dean

there are no tests proving this doesn't break in any Node environment when imported directly.

It still dose very much depends on compiling the source and consumers do still importing the build version. as there are not yet any place where it imports the original (uncompiled) source directly.

in any case. how do you propose we go about it and write a test for this? i don't believe just adding .js will "break" things

jimmywarting avatar Jan 15 '23 15:01 jimmywarting

It appears that the e2e test has failed, and it's not due to this PR. I will attempt to fix the CI. My pr for CI fix https://github.com/less/less.js/pull/3774

iChenLei avatar Jan 16 '23 03:01 iChenLei