hfhbd
05/05/2024, 8:59 AMnode_process_process_dcpv5o
?
// kotlin external library
package node.process
@JsModule("node:process")
external val process: Process
// Kotlin my code
val Context.token: String get() = process.env["GITHUB_TOKEN"]!!
// mjs:
import { ensureNotNull1e947j3ixpazm as ensureNotNull } from './kotlin-kotlin-stdlib.mjs';
import node_process_process_dcpv5o from 'node:process';
//region block: imports
//endregion
//region block: pre-declaration
//endregion
function get_token(_this__u8e3s4) {
return ensureNotNull(node_process_process_dcpv5o.env['GITHUB_TOKEN']);
}
//region block: exports
export {
get_token as get_token5mn2ctm2tja1,
};
//endregion
Instead of node_process_process_dcpv5o
, shouldn't it be process
?turansky
05/05/2024, 5:00 PMturansky
05/05/2024, 5:01 PMInstead ofIf mangling enabled (default) compiler can use any safe name 🙂, shouldn't it benode_process_process_dcpv5o
? (edited)process
hfhbd
05/05/2024, 5:02 PMhfhbd
05/05/2024, 5:02 PMturansky
05/05/2024, 5:04 PMhfhbd
05/05/2024, 5:05 PMturansky
05/05/2024, 5:07 PMturansky
05/05/2024, 5:07 PMprocess
, path
...hfhbd
05/05/2024, 5:08 PMprocess
from kotlin-wrappers then? 🤔turansky
05/05/2024, 5:09 PMprocess
and node:process
are equalturansky
05/05/2024, 5:09 PMnode:process
is saferturansky
05/05/2024, 5:11 PMimport nodeProcess from 'node:process'
nodeProcess === process // true
hfhbd
05/05/2024, 5:15 PMpackage node.process
@JsModule("process")
external val process: Process
So I guessed, it is due the (wrong) imports. Because webpack creates a runtime error wrongly using import.meta.url
when enabling es modules.
And now I don't know if this is a bug in kotlin-node, Kotlin compiler or web pack (my config or compiler).hfhbd
05/05/2024, 5:17 PMimport { process } from 'node:process'}
🤔turansky
05/05/2024, 5:28 PMimport nodeProcess from "node:process"
console.log(nodeProcess === process)
process
declaration and import are fineturansky
05/05/2024, 5:29 PMturansky
05/05/2024, 5:35 PMand as a workaround I use this without any importMagic 🙂 Looks like you calljs("'node:process'.process")
process
property from stringturansky
05/05/2024, 5:40 PM// Global
external val process: Process
turansky
05/05/2024, 5:43 PMprocess
onlyturansky
05/05/2024, 5:44 PMprocess.env.
) callturansky
05/06/2024, 6:33 AMGITHUB_TOKEN
val for start
@JsName("process.env.GITHUB_TOKEN") // process.env.GITHUB_TOKEN - token
external val GITHUB_TOKEN: String
But for fine solution custom tokens - my recommendation
@JsName("___GITHUB_TOKEN___") // ___GITHUB_TOKEN___ - token
external val GITHUB_TOKEN: String
external val
- guarantees, that you will have token in required place in JSturansky
05/18/2024, 8:56 AMhfhbd
05/18/2024, 9:17 AMes2022
target instead of node
but now I do have problems with some commonjs imports caused by the GitHub toolkit dependency.
This is my branch if you are interested: https://github.com/hfhbd/kotlin-actions/pull/55turansky
05/18/2024, 9:48 AMes2022
target for Webpack?hfhbd
05/18/2024, 10:19 AM