-
Notifications
You must be signed in to change notification settings - Fork 13
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
CLI: Simplify handling of imports #386
Conversation
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.
@josephjclark , this feels like an improvement as it allows the beta.each
and http.blah
stuff that we'll need to support from v1.
i see it's only in the CLI, should we be handling this in the worker/runtime also?
@taylordowns2000 Thank you for taking a look! In my head this was going to benefit the worker for free - but you're right, it only affects the CLI right now. I will add this to the worker in time for the next release. It's a bit of a scary change as it runs so deep (but it's not half so scary as a "full" fix in the Typescript compiler) |
@taylordowns2000 The other strategy is, as the Worker is about to come under loads of stress testing anyway, that we just raise this for the Worker and leave the CLI alone. We'll soon know if it's a net benefit or not. |
By the way I 100% guarantee that this approach will cause problems. It will for sure lead to misleading error messages and might catch out users who are doing weird stuff with global variables. The question is whether it'll fix more than it breaks! |
@josephjclark I am happy to report that
Here are some code to reproduce it sheetToBuffer(
[
{
name: {
first: 'John',
last: 'Adams',
},
},
],
{
wsName: 'Some Report',
bookType: 'csv',
}
); Side NoteLooking at the adaptor code i noticed that Could that be the reason ? |
Thank you @mtuchi! That's really helpful. I'll investigate and get back to you. Presumably the export is something to do with the issue - although really this fix should resolve it, in exactly the same way that http gets resolved. I'll have to dig into it. |
Hiya @josephjclark , Any update on this PR ?
|
I have also noticed if your using a {"message":"SyntaxError: The requested module '@openfn/language-common' does not provide an export named 'get'","name":"RuntimeCrash","severity":"crash","source":"runtime","subtype":"SyntaxError","type":"RuntimeCrash"} to resolve that i had to manually export
|
No update @mtuchi . It's on the list, but I'm not likely to get to it this month. Whatever solution we adopt needs to be rolled out in CLI and the Worker, so it's quite a bit of work. |
I am tempted to port this over to 1.0, although it's fairly low priority (and a bit risky still) so I may patch it in after |
@josephjclark do you still need me to test this ? |
@mtuchi Not at the moment, thank you! I'll try and get it sorted soon though |
Closing as this is properly fixed by #652 |
Short Description
Adds a
dumb-imports
option to the CLI by default.This should enable nested imports like
common.http
,common.beta
andmailchimp.md5
to work.Related issue
This is a workaround to #238, but closes #363 and the mailchimp md5 issue over in adaptors
Implementation Details
The CLI currently fails for jobs which reference any re-exported module from an adaptor. For example common exports
http
,beta
,dateFns
. All of these aliased exports (or nested namespaces?) will result in a Reference Error in the new CLI.For any job, we generate an import statement - eg,
import { fn, http } from '@openfn/language-common'
. To ensure this import statement is accurate, we look at the actual exports of the adaptor and try to only import what we need.The problem, which is broadly captured in #238, is that we are failing to get an accurate list of an adaptors exports. This mean that for
http
and other exports, no export is reported and so no import is generated. This results in a runtime exception because we're referencing an undefined symbol.To fix this properly we need to dig deeply into
describe-package
. Actually, we need to basically re-write it - see #197.This fix basically say: don't bother to look up the adaptor's actual imports, just assume that all undeclared variables are imported from the adaptor (apart from globals).
The risks of this change are:
x = 10
), the compiler will and import that variable from the adaptor. This will result in a runtime error. This is probably quite likely to happen.QA Notes
It would be helpful to re-test these issues (and close them, if they're not already)
mailchimp
bug wheremd5
cannot be used in the new CLI adaptors#383Checklist before requesting a review