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

Add export to GasPlugin for exporting its definition to dist/index.d.ts #10

Closed
wants to merge 1 commit into from

Conversation

Tei1988
Copy link
Contributor

@Tei1988 Tei1988 commented Apr 26, 2022

Hello.

When I have written an esbuild configuration in TypeScript, I could not import { GasPlugin } from esbuild-gas-plugin package because of no types exported in dist/index.d.ts.
So I add export keyword to GasPlugin.

In my local machine, it seems to work.

Anyway, thank you for publish this plugin.

@mahaker
Copy link
Owner

mahaker commented Apr 26, 2022

Thanks for using this plugin and contribution!

Does it work if use import GasPlugin from 'esbuild-gas-plugin instead of import { GasPlugin } from 'esbuild-gas-plugin ?

// index.ts
import GasPlugin from 'esbuild-gas-plugin'

console.log(GasPlugin)
> tsc && node dist/index.js

{ GasPlugin: { name: 'gas-plugin', setup: [Function: setup] } }

@mahaker
Copy link
Owner

mahaker commented Apr 26, 2022

my tsconfig.json

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "rootDir": "./src/",
    "outDir": "./dist/",
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true
  }
}

@Tei1988
Copy link
Contributor Author

Tei1988 commented Apr 26, 2022

Thank you for reply.

Does it work if use import GasPlugin from 'esbuild-gas-plugin instead of import { GasPlugin } from 'esbuild-gas-plugin ?

No, it does not work.

I tried to build using this script below:

import * as esbuild from 'esbuild'
import GasPlugin from 'esbuild-gas-plugin'

esbuild.build({
  entryPoints: ['src/main.ts'],
  bundle: true,
  outfile: 'dist/Code.gs',
  plugins: [GasPlugin]
})

and got this output below:

$ ts-node ./esbuild.ts
/src/node_modules/ts-node/src/index.ts:820
    return new TSError(diagnosticText, diagnosticCodes);
           ^
TSError: ⨯ Unable to compile TypeScript:
esbuild.ts:8:13 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type 'typeof import("/src/node_modules/esbuild-gas-plugin/dist/index")' is missing the following properties from type 'Plugin': name, setup

8   plugins: [GasPlugin]
...

This error seems that the type of GasPlugin is missing.

By the way, I found that my change is wrong becasuse of the compiled javascript is not work.
So I will close this PR.

I supposed that using export = { GasPlugin } instead of exports.GasPlugin = GasPlugin will resolve this situation.
Could I send new PR?

@Tei1988 Tei1988 closed this Apr 26, 2022
@Tei1988 Tei1988 deleted the main branch April 27, 2022 08:50
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

Successfully merging this pull request may close these issues.

None yet

2 participants