-
Notifications
You must be signed in to change notification settings - Fork 0
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
import.meta.url
workaround example
#2
Draft
thescientist13
wants to merge
6
commits into
master
Choose a base branch
from
new-url-workaround
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tried this import path from 'path';
const fakeImportMetaUrl = `file://${path.dirname(process.argv[1])}/`;
const dataUrl = new URL('../../public/data.json', fakeImportMetaUrl);
console.log({ fakeImportMetaUrl, dataUrl }); But still got an error 14:32:38.136 | ✨ Success! Uploaded 0 files (2 already uploaded) (0.40 sec)
-- | --
14:32:38.136 |
14:32:38.359 | ✨ Upload complete!
14:32:41.115 | Success: Assets published!
14:32:42.162 | Error: Failed to publish your Function. Got error: Uncaught TypeError: The "path" argument must be of type string. Received undefined at node-internal:validators:101:15 in validateString at node-internal:internal_path:1119:9 in dirname at functionsWorker-0.701045628589601.js:986:40 |
Trying this approach to extract the information from a Stack trace function getCurrentDirectory() {
const error = new Error();
Error.captureStackTrace(error);
const stack = error.stack;
console.log({ stack});
const callerLine = stack.split('\n')[2];
console.log({ callerLine });
const callerFile = callerLine.slice(callerLine.indexOf('file://')); // match(/file:\/\//)[0];
console.log({ callerFile });
const currentDir = `file:${path.dirname(callerFile.split(':')[1])}`; // path.dirname(callerFile);
console.log({ currentDir });
return currentDir;
} 14:49:37.844 | ✨ Compiled Worker successfully
-- | --
14:49:38.930 | Validating asset output directory
14:49:47.600 | Success: Assets published!
14:49:48.563 | Error: Failed to publish your Function. Got error: Uncaught TypeError: The "path" argument must be of type string. Received undefined at node-internal:validators:101:15 in validateString at node-internal:internal_path:1119:9 in dirname at functionsWorker-0.7477680660376456.js:995:35 in getCurrentDirectory at functionsWorker-0.7477680660376456.js:1000:25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
testing work arounds to using
import.meta.url
🤞Attempts
process.argv[1]
-import.meta.url
workaround example #2 (comment)