This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-01
Channels
I'm unable to import a local js file: HierarchyForm.js
import React from 'react'
import validator from '@rjsf/validator-ajv8';
import Form from "@rjsf/mui"
export default HierarchyForm = () => {
return (
);
};
But if I replace the Form with a plain div, it's importing fine. Are additional dependencies apart from React an issue here? I tried the same with MUI toootherwise I'm unsure what you are asking, this is not the right channel to ask JS questions 😛
Yes! Sorry! Importing it into a uix2 project using shadow-cljs
I've setup the gen path like the document suggests and using (require '["/js/test/HierarchyForm" :default HierarchyForm]) to import it
Oh I have used babel:
import React from 'react';
import validator from '@rjsf/validator-ajv8';
import Form from "@rjsf/mui";
export default HierarchyForm = () => {
return /*#__PURE__*/React.createElement(Form, {
schema: {
type: 'string'
},
validator: validator
});
};
Rational is that other teams can also use the plain JS files directly
currently multiple Typescript projects underway with this being the only CLJS project
if you are going to have a lot of JS I do not recommend including it this way. the direct JS import will get you in trouble, or rather that it is getting processed via the closure compiler
you probably either want :target :npm-module
or :esm
and let JS tools process the leftover JS
Oh so you're suggesting changing the shadow-cljs config to import this as is and then process via another tool? Curious how the React import gets by this problem
I don't know what the problem is, you can debug it. you didn't say what the error is so I have nothing to go by
the closure compiler is quite strict in how it handles import
, so there might be differences to how other JS tools do it
but if you have lots of JS code you are better off using :npm-module
and letting something like webpack process the JS
and put your JS files into some "package" so you import them via (:require ["your-package/HierachyForm" :as x])
or whatever
I see, let me try that. Btw here is the error in the console. Probably have something to do with the way the compiler is resolving the other dependencies? If I can share anything more detailed with you please let me know interim.