Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack loader plugin for importing .swift files directly #8

Open
KishanBagaria opened this issue Mar 19, 2022 · 0 comments
Open

Webpack loader plugin for importing .swift files directly #8

KishanBagaria opened this issue Mar 19, 2022 · 0 comments

Comments

@KishanBagaria
Copy link
Collaborator

This would be a nice to have:

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:

const { getTime } = require("./example.swift");
console.log(`Seconds since 1970: ${getTime()}`);
// Seconds since 1970: 1647672663

webpack.config.js:

module.exports = {
  module: {
    rules: [
      {
        test: /\.swift$/i,
        use: ["node-swift-loader"],
      },
    ],
  },
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant