1
00:00:01,300 --> 00:00:05,560
I'm back inside my code editor still looking at the unresolved function, so we're going to add in some

2
00:00:05,560 --> 00:00:12,100
code here and decide based upon the exact path argument to remember our path is the essentially path

3
00:00:12,100 --> 00:00:14,920
to the file that we are trying to require or import in.

4
00:00:15,460 --> 00:00:21,070
We are going to use that to decide whether or not we want to apply that new Eurail constructor that

5
00:00:21,070 --> 00:00:22,860
we looked at in the end of the last video.

6
00:00:23,650 --> 00:00:26,290
There are still going to do this in a slightly naive way.

7
00:00:26,500 --> 00:00:29,320
We're still not going to have a final solution here that works for all cases.

8
00:00:29,440 --> 00:00:33,700
We're kind of, as you can tell, kind of evolving our code over time and considering all these different

9
00:00:33,730 --> 00:00:39,460
ways that new modules can be imported or required into a project to write above our return statement.

10
00:00:40,090 --> 00:00:40,900
I'm going to add in.

11
00:00:41,500 --> 00:00:47,770
And if and we're going to use this if to decide whether or not we are working on some file that has

12
00:00:47,770 --> 00:00:49,150
a relative path in it.

13
00:00:49,180 --> 00:00:52,900
It's like a file that has a story to do.

14
00:00:52,900 --> 00:00:55,390
So we're going to take a look at args dot path.

15
00:00:56,200 --> 00:01:01,920
We're going to see if it includes, remember, our exact path that right there is like the dot slash

16
00:01:02,050 --> 00:01:04,540
utils or the slash utils.

17
00:01:04,810 --> 00:01:06,040
So we're going to look at that string.

18
00:01:06,390 --> 00:01:13,930
We're going to see if it includes a dot or our exact path includes a dot dot.

19
00:01:15,190 --> 00:01:20,200
If that is the case, then we're going to apply this special new umbrella constructor thing that we

20
00:01:20,200 --> 00:01:21,550
saw at the end of the last video.

21
00:01:22,450 --> 00:01:28,060
One, if you're going to return an object once again with a namespace of just a four right now, again,

22
00:01:28,060 --> 00:01:30,420
we're going to come back and adjust that at some point in time.

23
00:01:31,440 --> 00:01:36,300
And then our path will be new, you are, well, our paths.

24
00:01:37,240 --> 00:01:43,630
And we want to join on or use as the base domain, the importer, the file that tried to import this

25
00:01:43,630 --> 00:01:48,010
thing in our case, that is going to be our export importer.

26
00:01:49,940 --> 00:01:54,620
So for our application, the importer, as we saw inside that control log, would be like the unpackaged

27
00:01:54,620 --> 00:01:56,150
dotcom slash.

28
00:01:57,080 --> 00:02:03,050
Medium test package and then remember, very small critical detail right now is we have to get a Ford

29
00:02:03,560 --> 00:02:05,180
at the end of that base of.

30
00:02:06,660 --> 00:02:10,169
That's going to generate a real object, we don't care about the entire object.

31
00:02:10,190 --> 00:02:14,030
All we care about is that property that has the fully formed URL.

32
00:02:14,640 --> 00:02:17,840
We're going to do a dot HSF on the very end like so.

33
00:02:20,020 --> 00:02:24,780
OK, so this should fix the current problem, but like I said, still kind of a naive approach here.

34
00:02:25,210 --> 00:02:29,680
This still is not quite perfect and is not going to handle all test are all possible cases.

35
00:02:30,040 --> 00:02:33,160
I apologize for this kind of iterative approach that we're going through here.

36
00:02:33,370 --> 00:02:37,930
But honestly, if I just threw the completed code on the screen, you might say like, hey, what is

37
00:02:37,930 --> 00:02:38,490
going on?

38
00:02:38,650 --> 00:02:40,720
Why are there all these possible different cases?

39
00:02:40,930 --> 00:02:45,580
Well, we really have to see all the different ways that new modules can have import statements and

40
00:02:45,580 --> 00:02:49,630
require statements, all the different possible variations, a path to really understand how we're going

41
00:02:49,630 --> 00:02:52,090
to eventually come up with a good solution to this stuff.

42
00:02:52,870 --> 00:02:56,220
Having said that, let's say this, go back to the browser and see how we're doing.

43
00:02:57,130 --> 00:03:00,360
It's going to refresh, submit, and there we go.

44
00:03:00,850 --> 00:03:03,670
Sure enough, we are now able to bundle the entire application.

45
00:03:04,150 --> 00:03:11,740
So we are bundling our indexed JS file, which requires in medium test package and medium test packages.

46
00:03:11,740 --> 00:03:17,200
Indexed JS file in turn is attempting to require in utils.

47
00:03:18,040 --> 00:03:20,470
You'll notice that the very final onload down here.

48
00:03:21,880 --> 00:03:26,260
Remember, OnLoad is, when we are attempting to actually fetch the contents of a file, definitely

49
00:03:26,260 --> 00:03:31,300
is receiving the accurate path, that is definitely the path that we want to get to that utils file.

50
00:03:31,840 --> 00:03:36,370
Again, if we were to take that string right there and try to visit it inside the browser, we see the

51
00:03:36,400 --> 00:03:37,560
utils file load up.

52
00:03:38,260 --> 00:03:40,660
This definitely looks good, definitely works.

53
00:03:40,870 --> 00:03:44,770
But like I said, well, not going to work in all possible cases.

54
00:03:45,040 --> 00:03:49,540
There are still going to be some NPE modules out there that fail with our current kind of path generation

55
00:03:49,540 --> 00:03:49,950
stuff.

56
00:03:50,260 --> 00:03:53,410
So still a couple of very small corner cases that we need to consider.

57
00:03:53,980 --> 00:03:56,560
Let's take a look at one other variation in the next video.

