Giter Site home page Giter Site logo

Comments (3)

sindresorhus avatar sindresorhus commented on May 31, 2024

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#how-can-i-import-esm-in-electron

from run-applescript.

NL33 avatar NL33 commented on May 31, 2024

Thanks for the info here, but I am not yet able to get things to work. I have reviewed the resource you referenced, as well as the extended discussion about esm and Electron here. But there are some things about how esm works that I must be missing (I have not previously been familiar with the import / esm issue in electron).

I downloaded the esm package ($ npm i esm), and then brought it into my main.js per their docs:

require = require("esm")(module/*, options*/)
module.exports = require("./main.js")

But, still importing run-applescript in either my main js or renderer after bringing in esm, doesn't work. I've tried both:

import { runAppleScriptAsync } from './node_modules/run-applescript';

and
const runAppleScriptAsync = require('run-applescript')

I see that another option is using webpack, but I would prefer to avoid significant changes to my structure (which does not use webpack).

is there another way to use this package with esm?

from run-applescript.

NL33 avatar NL33 commented on May 31, 2024

Hi There. Still trying to find a way to use this with electron, but not having success yet. Trying to get this to work with ESM is currently a no-go it seems. And I'm not able to use webpack.

So, that leaves using a prior version that would allow a require statement.

From what I can tell, the last commit that would allow that would be this one from Jan 2021: https://github.com/sindresorhus/run-applescript/tree/dd9465af64f36e7775180997a20af0671ace43cd

Do you think that is acceptable for production for current version (12+) electron?

from run-applescript.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.