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

Use webpack instead of tsc to output extension-api.ts #1499

Merged
merged 5 commits into from
Nov 26, 2020

Conversation

chenhunghan
Copy link
Contributor

@chenhunghan chenhunghan commented Nov 24, 2020

The original script compile:extension-types (introduced in #1387) which uses tsc to output .d.ts didn't (completely) resolve issue #1262, because tsc only transpile .ts/tsx to .js

The require('module')/import in ts/tsx are the same after transpilation. Keeping require/import causes lensapp/generator-lens-ext#13 (see comments) for extension developers, when they try to import modules from @k8slens/extensions

The PR aims to use WebPack to solve the problem. I added a new webpack.extensions.ts, and used webpack + ts-loader to pack @k8slens/extensions as one file extension-api.js and output .d.ts just the same original tsc.

I tried to keep webpack.extensions.ts as simple as possible, so remove unnecessary settings which are in other more complicated settings such as webpack.renderer.ts or webpack.main.ts

Closes #1262

Signed-off-by: Hung-Han (Henry) Chen 1474479+chenhunghan@users.noreply.github.com

tsconfig.extensions.json Outdated Show resolved Hide resolved
@ixrock
Copy link
Member

ixrock commented Nov 24, 2020

Can't get what this PR fixing / improves?

@jakolehm
Copy link
Contributor

Can't get what this PR fixing / improves?

See: lensapp/generator-lens-ext#13

@ixrock
Copy link
Member

ixrock commented Nov 24, 2020

Can't get what this PR fixing / improves?

See: lensapp/generator-lens-ext#13

Ok, @chenhunghan please put next time relevant links in PR/issue description.

@chenhunghan
Copy link
Contributor Author

Can't get what this PR fixing / improves?

See: lensapp/generator-lens-ext#13

Ok, @chenhunghan please put next time relevant links in PR/issue description.

sure, it's a WIP draft so I didn't put too much attention on the description.

@chenhunghan chenhunghan marked this pull request as ready for review November 26, 2020 05:06
@chenhunghan
Copy link
Contributor Author

@jakolehm checks are passed, please take a look

Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
…tensions

Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
Signed-off-by: Hung-Han (Henry) Chen <1474479+chenhunghan@users.noreply.github.com>
@chenhunghan chenhunghan force-pushed the feature/webpack-output-extension branch from f36ba40 to c2e23bd Compare November 26, 2020 05:08
@jakolehm jakolehm added the area/extension Something to related to the extension api label Nov 26, 2020
@jakolehm jakolehm added this to the 4.0.0 milestone Nov 26, 2020
extensions: ['.ts', '.tsx', '.js']
},
plugins: [
// In ts-loader's README they said to output a built .d.ts file,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to leave it there as someone else might waste time trying...

@chenhunghan chenhunghan merged commit 95d7ff8 into master Nov 26, 2020
@chenhunghan chenhunghan deleted the feature/webpack-output-extension branch November 26, 2020 08:12
@jakolehm jakolehm mentioned this pull request Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export @k8slens/extensions for writing extension unit tests
3 participants