Skip to content
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/add diagnostics_channel shim #21

Merged

Conversation

JayaKrishnaNamburu
Copy link
Member

@JayaKrishnaNamburu JayaKrishnaNamburu commented Aug 7, 2021

#5

@JayaKrishnaNamburu JayaKrishnaNamburu force-pushed the feat/add-diagnostics_channel-shim branch from 4a3bd14 to b023447 Compare August 7, 2021 14:37
@@ -0,0 +1,4 @@
import dc, { channel, hasSubscribers, Channel } from "diagnostics_channel";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guybedford the build seems to fail. Looks like it is trying to resolve diagnostics_channel from node_modules/@jspm/core instead of node_modules/diagnostics_channel to add it in scope.
Here is the error

[!] (plugin @jspm/plugin-rollup) Error: ENOENT: no such file or directory, lstat '/Users/jkrishna/Documents/jspm/jspm-core/node_modules/@jspm/core/nodelibs/browser/diagnostics_channel.js'
Error: ENOENT: no such file or directory, lstat '/Users/jkrishna/Documents/jspm/jspm-core/node_modules/@jspm/core/nodelibs/browser/diagnostics_channel.js'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is because in Node.js core modules take precedence over installed ones. Instead the trick here is to reference ../node_modules/diagnostics_channel/....js in the import.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's trying to resolve from node_modules/@jspm/core/nodelibs/browser/diagnostics_channel.js right. Under @jspm/core of previous version. Which i have 2.0.0-beta.8 inside my node_modules. I think it is @jspm/plugin-rollup that is pulling the lastest version of @jspm/core available from npm.

@jspm/core@2.0.0-beta.8 /Users/jkrishna/Documents/jspm/jspm-core
└─┬ @jspm/plugin-rollup@1.1.0 (git+ssh://git@github.com/jspm/rollup-plugin-jspm.git#6da8627c351e216109fe8817232c99e23dae8324)
  ├── @jspm/core@2.0.0-beta.8
  └─┬ @jspm/generator@1.0.0-beta.11
    └── @jspm/core@2.0.0-beta.8 deduped

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it now, the rollup-jspm-plugin is trying to pull from @jspm/core which don't don't have in the older version. And yes, resolving from ./node_modules solves the issue 👍

@@ -109,6 +110,11 @@
"deno": "./nodelibs/browser/perf_hooks.js",
"node": "./nodelibs/node/perf_hooks.js",
"default": "./nodelibs/browser/perf_hooks.js"
},
"./nodelibs/diagnostics_channel": {
"deno": "./nodelibs/browser/diagnostics_channel.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forcing to use browser for deno too. Because, i highly doubt deno will be accepting PR's that uses external packages as dependencies.

@JayaKrishnaNamburu JayaKrishnaNamburu changed the title Feat/add diagnostics channel shim Feat/add diagnostics_channel shim Aug 9, 2021
Comment on lines 5 to 9
export default {
channel,
Channel,
hasSubscribers
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be export default dc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a weird bug, is it a Rollup bug? Did you try import dc from '../node_modules/diagnostics_channel/index.js? CommonJS modules (which this is) should always be imported that way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It happens only when i import like import dc from 'diagnostics_channel. But since i am importing using like
import * as dc ... now it works though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's wrong though... we should fix the builder then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@guybedford guybedford Aug 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is using import dc should work and that it isn't working is a bug!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather the import dc form.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So no bug there, the build was failing because, i missed index.js extension. But instead used just './node_modules/diagnostics_channel' for the import.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, it sounds like if anything the jspm-rollup issue might be to ensure a clearer error message in this case then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, i will check if i can do something and throw some useful error message there then 👍

@JayaKrishnaNamburu JayaKrishnaNamburu force-pushed the feat/add-diagnostics_channel-shim branch from 8f4cbd9 to 23d1ef9 Compare August 9, 2021 14:57
@guybedford guybedford merged commit 295b5b6 into jspm:main Aug 9, 2021
@guybedford
Copy link
Member

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants