This question already has answers here:
Is it possible to import modules from all files in a directory, using a wildcard?
(14 answers)
Closed 7 years ago.
Does the ES6 module syntax allow you to import something from a folder?
For example if I have ./sub/main.js and I try import foo from './sub in the ./main.js file, will this work?
Could I get this sort of importing from a folder to work with babel and webpack?
Basically this would be the equivalent of __init__.py in Python.
ES6's module syntax does not dictate how the module identifier should be interpreted.
That solely depends on the module loader / bundler you are using, which seems to be webpack. Not sure how easily it can be implemented, have a look at the documentation.
Related
This question already has answers here:
How can I have nice file names & efficient storage usage in my Foundry Magritte dataset export?
(3 answers)
Closed 6 months ago.
I have a PySpark transform in Palantir Foundry that's outputting to a csv file for export into other systems.
Currently, using the write_dataframe method the name of the file looks like this:
spark/part-00002-cfba77d5-c6ce-4b2a-ac9a-59173c7ede5a-c000.snappy.csv
is it possible to specify a filename, such as "my_export.csv" ?
It's likely easier to accomplish this using an export task rather than via a transform. Some documentation on export tasks is available here, but it is described in more detail in the in-platform docs.
If you're using a file system or SFTP export task, there is an option to rewrite paths in the task config. For example,
rewritePaths:
".*": "my_export.csv"
would rename all files to my_export.csv. I wouldn't recommend doing exactly that, as you'll have a collision if there are multiple files, but you can also capture part of the existing file name and use it to make the renamed files unique:
rewritePaths:
"^spark/(.*)": "my_export-$1.csv"
This question already has answers here:
angular2 http.post() to local json file
(2 answers)
Closed 2 years ago.
I am using angular to create an application and has a requirement to store a json object currently stored in a variable to file.json located in src/app/assets using angular.
I have searched a lot and have not found a way to do this.
Ask if need any more information.
You cannot write files with Angular. Don't forget that the Angular app is not running in the directory structure you create. It's not even running on a server. It's running in the browser as compiled JavaScript. It has no direct write access to any filesystem.
If you need to write to server-side files in your application, you need some server-side code. This can be achieved, for example, with NodeJS (Express, NestJSā¦) if you want to stick with JavaScript. Either way, you can't write files directly with Angular.
Dears,
I'm trying to make GraphQL work with Polymer 3 (or lit-html)
Trying to use apollo-client (which seems has adapters for polymer-elements and lit-html) and stuck with problem of importing CommonJS modules (i.e. module.export) in Polymer:
Uncaught SyntaxError: The requested module '../../graphql/language/visitor.js' does not provide an export named 'visit'
Correct me if I'm wrong, but if apollo-client provides apollo-client/polymer and apollo-client/lit-apollo this should work somehow. I tried to do it by included guides but got no success.
You'll have to use a build-time transform (e.g. a bundler like webpack) if you want to load a commonjs module via ES module import syntax.
Commonjs modules (require(...), exports.foo = ...) are very different from ES modules, and usually require some pre-processing before they're loadable in the browser.
I have a styles.css file and I need to load it from a cljs to pass it as a props to a react lib.
The import in node is:
import styles from './styles.css'
Is it possible to do this in ClojureScript with shadow-cljs?
Importing styles.css in webpack is handled by the style-loader which you can sort of hook up by following the webpack guide and exporting things to global objects.
ClojureScript itself (or shadow-cljs) does not support anything in that regard but you could possibly create something similar using macros.
This question already has answers here:
Collapse multiple submodules to one Cython extension
(5 answers)
Closed 2 years ago.
I have multiple .py files in one package
packageA
\__init__.py
\mod1.py
\mod2.py
\mod3.py
can I config cython to compile and then packing them all in one packageA.pyd ?
Personally, I would better turn all the .py files into .pyx, then include them into the main .pyx of the Cython extension:
packageA.pyx:
include "mod1.pyx"
include "mod2.pyx"
include "mod3.pyx"
Then, compile using a setup.py looking like:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [
Extension("packageA", sources=["packageA.pyx"])
]
)
Running this would generate an all in one packageA.pyd binary file.
Of course, this will output a single module named packageA, and I don't know if this is acceptable for you, or if you really need distinct modules in your package.
But there might be other ways that better fit your question...