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

Fix CDN build targets #270

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ module.exports = {
"@typescript-eslint/ban-types": 0,
"@typescript-eslint/no-unsafe-call": 0,
"@typescript-eslint/await-thenable": 0,
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-unsafe-return": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-floating-promises": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"@typescript-eslint/no-useless-constructor": 0,
"@typescript-eslint/no-unsafe-member-access": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/restrict-template-expressions": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
},

settings: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"brotli-size": "^4.0.0",
"chalk": "~4.1.2",
"enquirer": "^2.3.6",
"esbuild": "^0.13.15",
"esbuild": "^0.14.13",
"eslint": "~7.3.1",
"eslint-import-resolver-typescript": "~2.0.0",
"eslint-plugin-import": "~2.21.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/@magic-ext/algorand/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AlgorandExtension } from './index';

export type { AlgorandExtension as default };
module.exports = AlgorandExtension;
export default AlgorandExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/avalanche/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AvalancheExtension } from './index';

export type { AvalancheExtension as default };
module.exports = AvalancheExtension;
export default AvalancheExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/bitcoin/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BitcoinExtension } from './index';

export type { BitcoinExtension as default };
module.exports = BitcoinExtension;
export default BitcoinExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/cosmos/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CosmosExtension } from './index';

export type { CosmosExtension as default };
module.exports = CosmosExtension;
export default CosmosExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/flow/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { FlowExtension } from './index';

export type { FlowExtension as default };
module.exports = FlowExtension;
export default FlowExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/harmony/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { HarmonyExtension } from './index';

export type { HarmonyExtension as default };
module.exports = HarmonyExtension;
export default HarmonyExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/icon/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IconExtension } from './index';

export type { IconExtension as default };
module.exports = IconExtension;
export default IconExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/near/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NearExtension } from './index';

export type { NearExtension as default };
module.exports = NearExtension;
export default NearExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/oauth/src/index.cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ Object.assign(OAuthExtension, {
...types,
});

export type { OAuthExtension as default };
module.exports = OAuthExtension;
export default OAuthExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/polkadot/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PolkadotExtension } from './index';

export type { PolkadotExtension as default };
module.exports = PolkadotExtension;
export default PolkadotExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/solana/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { SolanaExtension } from './index';

export type { SolanaExtension as default };
module.exports = SolanaExtension;
export default SolanaExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/tezos/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { TezosExtension } from './index';

export type { TezosExtension as default };
module.exports = TezosExtension;
export default TezosExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/webauthn/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { WebAuthnExtension } from './index';

export type { WebAuthnExtension as default };
module.exports = WebAuthnExtension;
export default WebAuthnExtension;
3 changes: 1 addition & 2 deletions packages/@magic-ext/zilliqa/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ZilliqaExtension } from './index';

export type { ZilliqaExtension as default };
module.exports = ZilliqaExtension;
export default ZilliqaExtension;
5 changes: 2 additions & 3 deletions packages/magic-sdk/src/index.cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { SDKBase, createSDK } from '@magic-sdk/provider';
import * as publicAPI from '@magic-sdk/commons';
import localForage from 'localforage';
import memoryDriver from 'localforage-driver-memory';
import * as memoryDriver from 'localforage-driver-memory';
import { IframeController } from './iframe-controller';

// NOTE: enums are emitted by TypeScript -- in the CDN bundle we attach public
Expand Down Expand Up @@ -31,5 +31,4 @@ const Magic = Object.assign(
{ ...publicAPI },
);

module.exports = Magic;
export type { Magic as default };
export default Magic;
3 changes: 1 addition & 2 deletions scripts/bin/scaffold/template/hybrid/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { <%= className %> } from './index';

export type { <%= className %> as default };
module.exports = <%= className %>;
export default <%= className %>;
3 changes: 1 addition & 2 deletions scripts/bin/scaffold/template/web/src/index.cdn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { <%= className %> } from './index';

export type { <%= className %> as default };
module.exports = <%= className %>;
export default <%= className %>;
11 changes: 11 additions & 0 deletions scripts/utils/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ export async function build(options: ESBuildOptions) {
Object.entries(environment).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),
),
plugins: [...globalsPlugin(options.globals || {})],

// We need this footer because: https://github.com/evanw/esbuild/issues/1182
footer:
options.format === 'iife'
? {
// This snippet replaces `window.{name}` with
// `window.{name}.default`, with any additional named exports
// assigned. Finally, it removes `window.{name}.default`.
js: `if (${options.name} && ${options.name}.default != null) { ${options.name} = Object.assign(${options.name}.default, ${options.name}); delete ${options.name}.default; }`,
Copy link
Contributor

Choose a reason for hiding this comment

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

ooofduuh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I hate it. But it works...

}
: undefined,
});

// Log the type and size of the output(s)...
Expand Down
Loading