Question: It sounds like you just want to add an import declaration node?

Asked By
rattrayalex
Asked At
2017-09-19 06:20:39

Found 15 possible answers.

User Answered At Possible Answer
wagonofjustice 2017-09-20 00:26:19 Hiya, if anyone can instruct me how to create myArray[0] in babel, that'd be great
andarist 2017-09-20 07:52:09 https://astexplorer.net/ is great for looking what AST you’d like to produce t.memberExpression(t.identifier(‘myArray’), t.numericLiteral(0), true) it seems it will be something like to see what arguments certain builders need + i always look here https://github.com/babel/babel/tree/master/packages/babel-types
wagonofjustice 2017-09-20 18:59:18 its the computed part I was missing
andarist 2017-09-22 23:25:00 im trying to use babel-helper-plugin-test-runner in my project
but it dont want to find my plugin, im geting
ReferenceError: Unknown plugin "/Users/user/babel-plugin-my-plugin/node_modules/babel-helper-transform-fixture-test-runner/lib/../../babel-plugin-my-plugin" specified in "base" at 0, attempted to resolve relative to "/Users/user/babel-plugin-annotate-pure-calls/test/fixtures/spec/test-case"
}
  "plugins": ["my-plugin"]
{ and have provided options.json
loganfsmyth 2017-09-22 23:28:13 Maybe try a relative path?
andarist 2017-09-22 23:28:26 the value of the path is comming from this line - https://github.com/babel/babel/blob/0f8c4dc5a1af6580d980252de7ad90649d0672d4/packages/babel-helper-transform-fixture-test-runner/src/index.js#L125 maybe the problem is hm const taskOptsLoc = resolve(taskDir + "/options"); but thats comming from here https://github.com/babel/babel/blob/0f8c4dc5a1af6580d980252de7ad90649d0672d4/packages/babel-helper-fixtures/src/index.js#L108-L112 i would have to provide optionsDir - https://github.com/babel/babel/blob/0f8c4dc5a1af6580d980252de7ad90649d0672d4/packages/babel-helper-transform-fixture-test-runner/src/index.js#L137 because of the way it resolves i would have to specify options.json in each test case directory but from what i dug up from the source code well, ive tried then it works >.< and if i change it to val[0] = require.resolve("babel-" + type + "-" + val[0]);
existentialism 2017-09-22 23:33:58 there’s a lot that leaves to be desired in test-runner :slightly_smiling_face:
andarist 2017-09-22 23:34:19 that im trying to load my plugin from the symlink? :thinking_face: i guess id have to dig deeper 2morrow to see why the same-ish thing works in the babel repo
rattrayalex 2017-09-23 04:06:41 @andarist I don't recall but self-linking may help. Eg npm link && npm link my-package from within package root
andarist 2017-09-23 07:04:03 ok, ill check this out, need to read out what npm link does, forgot that there is such an option - never have used it
    "pretest": "if [ ! -d ./node_modules/$npm_package_name ]; then npm run self-link; else npm run build; fi",
I have ended up with a weirdo
"self-link": "npm link && npm link $npm_package_name", do u know any reason why is it doing this?
preinstall
preuninstall
i end up with
preinstall
npm link
npm link
and
npm link
  }
    "preuninstall": "echo 'preuninstall'"
    "preinstall": "echo 'preinstall'",
"scripts": { so with such config consecutive npm link calls result in installs and uninstalls however ive encountered a weird thing @rattrayalex self-linking resolved my issue ( at least it looks like so :wink: ) ! thanks "postinstall": "if [ ! -d ./node_modules/$npm_package_name ]; then ln -s . ./node_modules/$npm_package_name; fi", ive created a symlink “manually”
loganfsmyth 2017-09-23 18:34:37 @andarist Didn't have time to respond yesterday, but did using a normal relative path not work? As far as I know, that's the recommended approach
andarist 2017-09-23 20:05:12 @loganfsmyth nope, couldnt make it work because of this https://github.com/babel/babel/blob/2374062bbdfe8815892d64bd797298805db8b150/packages/babel-helper-transform-fixture-test-runner/src/index.js#L116-L119 i could ofc misconfigured it somehow, but ive spent some time in a debugger because of this and i believe im not wrong (described this in more details few comment above)
loganfsmyth 2017-09-23 20:21:11 I guess I'm confused, don't you have that if you're making the options.json to put the plugin name inside of? If it's null, that seems like a bug
andarist 2017-09-23 20:25:02 hm, optionsDir is a test case directory where taskDir is a single test case’s dir where I do not want to keep my options.json
}
 // …
  optionsDir: taskOptsLoc ? path.dirname(taskOptsLoc) : null,
  // …
const test {
// …
const taskOptsLoc = resolve(taskDir + "/options"); and optionsDir is defined as optionsDir: taskOptsLoc ? path.dirname(taskOptsLoc) : null, and I want to have just single options.json in a root of the fixtures
loganfsmyth 2017-09-23 20:47:56 ahh I see I guess we'd really want to do that plugin path resolution inside https://github.com/babel/babel/blob/0f8c4dc5a1af6580d980252de7ad90649d0672d4/packages/babel-helper-fixtures/src/index.js#L62 where we have the path for each individual options.json since there are 3 possible locations for it yeah okay, that was just poorly implemented then

Related Questions