Open KishanBagaria opened 2 years ago
This would be a nice to have:
example.swift:
example.swift
import Foundation import NodeAPI @main struct MyExample: NodeModule { let exports: NodeValueConvertible init() throws { exports = [ "getTime": try NodeFunction { _ in Date().timeIntervalSince1970.rounded(.down) } ] } }
index.js:
index.js
const { getTime } = require("./example.swift"); console.log(`Seconds since 1970: ${getTime()}`); // Seconds since 1970: 1647672663
webpack.config.js:
webpack.config.js
module.exports = { module: { rules: [ { test: /\.swift$/i, use: ["node-swift-loader"], }, ], }, };
This would be a nice to have:
example.swift
:index.js
:webpack.config.js
: