Skip to content

Commit

Permalink
remove import.meta.url to solve test compatability issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Aug 28, 2024
1 parent ddb82e8 commit ea3a382
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/build/stable/commands/compile/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getBuildOptions(ts: string): BuildOptions {
setup(build): void {
build.onResolve(
{
filter: /^internal$|^util$|^fs$|^fmt$|^assert$|^buffer$|^path$|^stream$|^process$|^url$|^events$|^string_decoder$|^punycode$|^querystring$|^whatwg_url$|^encoding$|^http$|^os$|^crypto$|^zlib$|^internal\/deps\/acorn\/acorn\/dist\/acorn$|^internal\/deps\/acorn\/acorn-walk\/dist\/walk$|^perf_hooks$|^async_hooks$|^https$|^_node:fs$|^_node:os$|^_node:crypto$|^qjs:os$|^_encoding$|^wasi_net$|^wasi_http$/
filter: /^internal$|^util$|^fs$|^fs\/promises$|^fmt$|^assert$|^buffer$|^path$|^stream$|^process$|^url$|^events$|^string_decoder$|^punycode$|^querystring$|^whatwg_url$|^encoding$|^http$|^os$|^crypto$|^zlib$|^internal\/deps\/acorn\/acorn\/dist\/acorn$|^internal\/deps\/acorn\/acorn-walk\/dist\/walk$|^perf_hooks$|^async_hooks$|^https$|^_node:fs$|^_node:os$|^_node:crypto$|^qjs:os$|^_encoding$|^wasi_net$|^wasi_http$/
},
(args) => {
throw new Error(experimentalMessage(args.path));
Expand Down
20 changes: 3 additions & 17 deletions src/lib/experimental/experimental.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
if (globalThis._azleExperimental !== true) {
const importName = getImportName();

throw new Error(experimentalMessage(importName));
}

function getImportName(): string {
if (import.meta.url.includes('azle/src/lib/experimental')) {
return 'azle/experimental';
}

throw new Error(
`Azle: Experimental import name for module path ${
import.meta.url
} has not been created`
);
throw new Error(experimentalMessage());
}

function experimentalMessage(importName: string): string {
return `Azle: experimental mode must be enabled to import from ${importName}. You can enable experimental mode in your dfx.json file like this:
function experimentalMessage(): string {
return `Azle: experimental mode must be enabled to import from azle/experimental. You can enable experimental mode in your dfx.json file like this:
{
"canisters": {
"canisterName": {
Expand Down

0 comments on commit ea3a382

Please sign in to comment.