New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support web standard modules #7365
Conversation
Okay the sad thing is I had to change how we were running Mocha tests to build the .js files and then run them. Which sort of sucks because it takes 4x longer... but it's still 12s vs 4s. It's probably worth investigating ditching mocha or looking into a better test runner set up. But that's a huge undertaking and I really don't want to deal with it. I think the trade off here is worth it. |
Adds an esm import integration test and updates the commonjs integration test.
I also fixed our existing import integration test to work a little better with this setup, and I added another test to make sure that esm imports are working okay. |
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = dirname(__filename); | ||
|
||
async function main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This integration test will load up index.html
(in the same directory) and check <script type="module"></script>
web module imports.
See browser-test.js
for the other half of these tests.
@@ -0,0 +1,35 @@ | |||
import { Observable, from, map } from './node_modules/rxjs/dist/esm/index.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a rough set of imports and tests to assert that module imports are working okay.
|
||
assert(results.length === 3, 'from should work'); | ||
|
||
window.reportDone(success); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called with true
if everything is fine and false
if the there was any problem at all.
<title>RxJS Import Integration Test</title> | ||
</head> | ||
<body> | ||
<script type="module" src="./browser-test.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be honest, this is the first "real" <script type="module">
I've ever written.
you also want to add the & your build before your test is necessary in master too if you remove the path mappings patch you had. i wouldn't move off mocha because of it |
Doesn't seem to be necessary. |
are you sure? if i import something like i could import just wanna be sure we get this right 🙏 i could be wrong ofc. we can export wildcards i think btw, to avoid having to write each one manually in the map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's ugly - the .js
in the .ts
files - but it works.
Feel free to add a test. Right now at least we know it works with node mjs, cjs, web modules, vite, and webpack. |
BTW: It looks like we already had rxjs/packages/rxjs/package.json Lines 18 to 58 in d787879
|
its that the exported path ( i.e. in a repo where we're required to have file extensions on imports, we'd have to explicitly ignore basically because the real paths are not exported. so it may be we just need otherwise we would try it only really matters in projects with that level of strictness on imported paths though (e.g. one which isn't bundled, so needs the exact relative path rather than a non-existent alias). but would be nice to sort at some point |
I guess what I'm saying is: I can't prioritize this right now. If you want to set up an integration test that proves something is broken without such a change, and then make the change, that would be welcome. |
Ofc, no worries. Just wanted to explain what I meant Definitely belongs in another pr. If I get time some day I'll have a stab at it |
Literally just makes sure we're importing with
.js
extensions everywhere, so the output has those extensions as well.