Comments (16)
hmm see https://github.com/egoist/konan#api
from konan.
Not sure I get this. You pass a file entry point ('path_to_file.js') to 'detective' ... I can't seem to understand this sentense:
Source content as string or AST tree.
What is 'Source content'? And I thought that an AST would be what I would get back from konan, not pass into it ... !?
So I ask again:
Can it be used like this?:
let result = konan( 'path/to/script_to_traverse.js' );
from konan.
I can only generate this error: Error: You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a undefined node without passing scope and parentPath.
Which does not help me in 'guessing' what to pass to the module. Maybe the 'Like detective but also supports ES6 import and more.'
statement is not the right thing to state in the beginning of the readme. As it seem to give the wrong impression ...
from konan.
Source content means the JS code/AST you want to traverse.
from konan.
But then I need ANOTHER module to get the AST from the code!? I would expect konan to return THAT based upon a file path I pass to it ... !?
from konan.
It's VERY confusing!
from konan.
Could you please provide an example where you simply pass in a file path as a string ... IF that's how I can use it!
from konan.
This code:
konan(`
import React, {Component} from 'react'
const vue = require('vue/dist/vue')
import('./my-async-module').then()
require(path.resolve('./'))
`)
simply doesn't make any sense.
from konan.
'detective' works like this:
var detective = require('detective');
var fs = require('fs');
var src = fs.readFileSync(__dirname + '/strings_src.js');
var requires = detective(src);
console.dir(requires);
And I can't see how that matches how 'konan' works ... ?
from konan.
like I said, code or AST:
const code = `
console.log('js code')
`
konan(code)
//-------------- or hmm read the content from a script
const fs = require('fs')
const content = fs.readFileSync('./your/script', 'utf8')
konan(content)
//-------------- or if you already have an AST tree
konan(ast)
Does this make sense to you?
from konan.
Well, it only tell me that the module does NOT work like 'detective`.
And that's why I get errors when trying to do this:
const konan = require('konan');
let src = fs.readFileSync( path + '/index.js' ); // path is the path to the module folder.
let requires = konan( src );
console.log("Requires", requires, src);
from konan.
It keep throwing this at me:
Error: You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a undefined node without passing scope and parentPath.
Please, provide complete example of what scope
and parenPath
is ...
from konan.
There're edge cases when it says like
but not same
The input
must be a utf8
string not the buffer you're currently passing to konan
from konan.
I've done this as well, but still the same:
const detective = require('detective');
const konan = require('konan');
let src = fs.readFileSync( path + '/index.js', 'utf8');
let requires = konan( src );
console.log("Requires", requires, src);
from konan.
https://github.com/egoist/konan/blob/master/test/index.test.js
it works for me
from konan.
@sabsaxo I think you should make an example by codesandbox
from konan.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from konan.