| @@ -0,0 +1,14 | |||||
|
|
1 | { | |||
|
|
2 | "version": "0.2.0", | |||
|
|
3 | "configurations": [ | |||
|
|
4 | { | |||
|
|
5 | "name": "Launch browser tests", | |||
|
|
6 | "type": "node", | |||
|
|
7 | "request": "launch", | |||
|
|
8 | "program": "${workspaceFolder}/build/test/tests/index.js", | |||
|
|
9 | "cwd": "${workspaceFolder}/build/test", | |||
|
|
10 | "sourceMaps": true, | |||
|
|
11 | "preLaunchTask": "Build browser test" | |||
|
|
12 | } | |||
|
|
13 | ] | |||
|
|
14 | } No newline at end of file | |||
| @@ -0,0 +1,15 | |||||
|
|
1 | { | |||
|
|
2 | "version": "2.0.0", | |||
|
|
3 | "command": "./gradlew", | |||
|
|
4 | "type": "shell", | |||
|
|
5 | "tasks": [ | |||
|
|
6 | { | |||
|
|
7 | "label": "Build browser test", | |||
|
|
8 | "args": [ | |||
|
|
9 | "assembleTest", | |||
|
|
10 | "-Psymbols=local", | |||
|
|
11 | "-Pflavour=browser" | |||
|
|
12 | ] | |||
|
|
13 | } | |||
|
|
14 | ] | |||
|
|
15 | } No newline at end of file | |||
| @@ -1,260 +1,225 | |||||
| 1 | plugins { |
|
1 | plugins { | |
| 2 | id "org.implab.gradle-typescript" version "1.0.1-rc3" |
|
2 | id "org.implab.gradle-typescript" version "1.0.1-rc3" | |
| 3 | id "org.implab.gradle-hg" |
|
3 | id "org.implab.gradle-hg" | |
| 4 | id "ivy-publish" |
|
4 | id "ivy-publish" | |
| 5 | } |
|
5 | } | |
| 6 |
|
6 | |||
| 7 | // Π΅ΡΠ»ΠΈ Π²Π΅ΡΡΠΈΡ ΡΠ²Π½ΠΎ Π½Π΅ Π·Π°Π΄Π°Π½Ρ Π²ΡΡΠΈΡΠ»ΡΠ΅ΠΌ Π΅Π΅ ΠΈΠ· ΡΡΠ³Π° ΡΠ΅Π²ΠΈΠ·ΠΈΠΈ v.{num}*** |
|
7 | if (!symbols in ['local', 'pack', 'none']) | |
| 8 | // ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠΎΠΌ Π±ΡΠ΄Π΅Ρ Π²Π΅ΡΡΠΈΡ '{num}.{distance}' Π³Π΄Π΅ distance - ΡΠ°ΡΡΡΠΎΡΠ½ΠΈΠ΅ ΠΎΡ |
|
8 | throw new Exception("The symbols property value is invalid: $symbols"); | |
| 9 | // ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΠ΅Π²ΠΈΠ·ΠΈΠΈ Π΄ΠΎ ΡΠ΅Π²ΠΈΠ·ΠΈΠΈ Ρ ΡΡΠ³ΠΎΠΌ |
|
9 | ||
| 10 | def tagDistance = 0; |
|
10 | if (!flavour in ['browser', 'node']) | |
|
|
11 | throw new Exception("The flavour property value is invalid: $flavour"); | |||
| 11 |
|
12 | |||
| 12 | ext { |
|
13 | ext { | |
| 13 | packageName = "@$npmScope/$name" |
|
14 | packageName = flavour == 'browser' ? "@$npmScope/$name-amd" : "@$npmScope/$name" | |
| 14 | lint = project.hasProperty('lint') ? lint : false |
|
15 | lint = project.hasProperty('lint') ? project.lint : false | |
| 15 | } |
|
|||
| 16 |
|
||||
| 17 | configurations { |
|
|||
| 18 |
|
||||
| 19 | } |
|
16 | } | |
| 20 |
|
17 | |||
| 21 | sources { |
|
18 | sources { | |
| 22 | amd { |
|
19 | amd { | |
| 23 | typings { |
|
20 | typings { | |
| 24 | srcDir main.output.typingsDir |
|
21 | srcDir main.output.typingsDir | |
| 25 | } |
|
22 | } | |
| 26 | } |
|
23 | } | |
| 27 |
|
24 | |||
| 28 | cjs { |
|
25 | cjs { | |
| 29 | typings { |
|
26 | typings { | |
| 30 | srcDir main.output.typingsDir |
|
27 | srcDir main.output.typingsDir | |
| 31 | } |
|
28 | } | |
| 32 | } |
|
29 | } | |
| 33 |
|
30 | |||
| 34 | testAmd { |
|
31 | testAmd { | |
| 35 | typings { |
|
32 | typings { | |
| 36 | srcDir main.output.typingsDir |
|
33 | srcDir main.output.typingsDir | |
| 37 | srcDir amd.output.typingsDir |
|
34 | srcDir amd.output.typingsDir | |
| 38 | srcDir test.output.typingsDir |
|
35 | srcDir test.output.typingsDir | |
| 39 | } |
|
36 | } | |
| 40 | } |
|
37 | } | |
| 41 |
|
38 | |||
| 42 | testCjs { |
|
39 | testCjs { | |
| 43 | typings { |
|
40 | typings { | |
| 44 | srcDir main.output.typingsDir |
|
41 | srcDir main.output.typingsDir | |
| 45 | srcDir cjs.output.typingsDir |
|
42 | srcDir cjs.output.typingsDir | |
| 46 | srcDir test.output.typingsDir |
|
43 | srcDir test.output.typingsDir | |
| 47 | } |
|
44 | } | |
| 48 | } |
|
45 | } | |
| 49 | } |
|
46 | } | |
| 50 |
|
47 | |||
| 51 | typescript { |
|
48 | typescript { | |
| 52 | compilerOptions { |
|
49 | compilerOptions { | |
| 53 | types = [] |
|
50 | types = [] | |
| 54 | declaration = true |
|
51 | declaration = true | |
|
|
52 | ||||
|
|
53 | if(symbols != 'none') { | |||
| 55 | sourceMap = true |
|
54 | sourceMap = true | |
| 56 | sourceRoot = "_src" |
|
55 | sourceRoot = "_src" | |
| 57 | } |
|
56 | } | |
|
|
57 | ||||
|
|
58 | if (flavour == 'node') { | |||
|
|
59 | module = "commonjs" | |||
|
|
60 | target = "es2017" | |||
|
|
61 | lib = ["es2017", "dom", "scripthost"] | |||
|
|
62 | } else if (flavour == 'browser') { | |||
|
|
63 | module = "amd" | |||
|
|
64 | target = "es5" | |||
|
|
65 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable" ] | |||
|
|
66 | } | |||
|
|
67 | } | |||
| 58 | tscCmd = "$projectDir/node_modules/.bin/tsc" |
|
68 | tscCmd = "$projectDir/node_modules/.bin/tsc" | |
| 59 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" |
|
69 | tsLintCmd = "$projectDir/node_modules/.bin/tslint" | |
| 60 | esLintCmd = "$projectDir/node_modules/.bin/eslint" |
|
70 | esLintCmd = "$projectDir/node_modules/.bin/eslint" | |
| 61 | npmCmd = "npm" |
|
71 | npmCmd = "npm" | |
| 62 | } |
|
72 | } | |
| 63 |
|
73 | |||
| 64 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|||
| 65 | dependsOn "prepare" |
|
|||
| 66 | } |
|
|||
| 67 |
|
||||
| 68 | tasks.matching{ it.name =~ /^lint/ }.configureEach { |
|
74 | tasks.matching{ it.name =~ /^lint/ }.configureEach { | |
| 69 | onlyIf { lint } |
|
75 | onlyIf { lint } | |
| 70 | } |
|
76 | } | |
| 71 |
|
77 | |||
| 72 | task prepare { |
|
78 | if (symbols == 'local') { | |
| 73 |
|
79 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { | ||
|
|
80 | compilerOptions { | |||
|
|
81 | sourceRoot = "file://" + it.rootDir | |||
|
|
82 | } | |||
|
|
83 | } | |||
| 74 | } |
|
84 | } | |
| 75 |
|
85 | |||
| 76 | task printVersion { |
|
86 | task printVersion { | |
| 77 | dependsOn prepare |
|
|||
| 78 |
|
||||
| 79 | doLast { |
|
87 | doLast { | |
|
|
88 | println "packageName: ${-> packageName}"; | |||
| 80 | println "version: ${-> version}"; |
|
89 | println "version: ${-> version}"; | |
| 81 |
println " |
|
90 | println "flavour: ${-> flavour}"; | |
| 82 | println "target: ${-> typescript.compilerOptions.target}"; |
|
91 | println "target: ${-> typescript.compilerOptions.target}"; | |
| 83 | println "module: ${-> typescript.compilerOptions.module}"; |
|
92 | println "module: ${-> typescript.compilerOptions.module}"; | |
|
|
93 | println "lint: ${-> lint}"; | |||
|
|
94 | println "symbols: ${-> symbols}"; | |||
| 84 | } |
|
95 | } | |
| 85 | } |
|
96 | } | |
| 86 |
|
97 | |||
| 87 | task clean { |
|
98 | task clean { | |
| 88 | prepare.mustRunAfter it |
|
|||
| 89 |
|
||||
| 90 | doLast { |
|
99 | doLast { | |
| 91 | delete buildDir |
|
100 | delete buildDir | |
| 92 | } |
|
101 | } | |
| 93 | } |
|
102 | } | |
| 94 |
|
103 | |||
| 95 | npmPackMeta { |
|
104 | npmPackMeta { | |
| 96 | meta { |
|
105 | meta { | |
| 97 | name = packageName |
|
106 | name = packageName | |
| 98 | } |
|
107 | } | |
| 99 | } |
|
108 | } | |
| 100 |
|
109 | |||
| 101 | configureTsCjs { |
|
110 | configureTsCjs { | |
| 102 | dependsOn sources.main.output |
|
111 | dependsOn sources.main.output | |
| 103 | compilerOptions { |
|
112 | compilerOptions { | |
| 104 | types += [ "node" ] |
|
113 | types += [ "node" ] | |
| 105 | } |
|
114 | } | |
| 106 | } |
|
115 | } | |
| 107 |
|
116 | |||
| 108 | configureTsAmd { |
|
117 | configureTsAmd { | |
| 109 | dependsOn sources.main.output |
|
118 | dependsOn sources.main.output | |
| 110 | compilerOptions { |
|
119 | compilerOptions { | |
| 111 | types += [ "requirejs", "dojo-typings" ] |
|
120 | types += [ "requirejs", "dojo-typings" ] | |
| 112 | } |
|
121 | } | |
| 113 | } |
|
122 | } | |
| 114 |
|
123 | |||
| 115 | test { |
|
124 | test { | |
| 116 | workingDir layout.buildDirectory.dir("test"); |
|
125 | workingDir layout.buildDirectory.dir("test"); | |
| 117 | commandLine "node", "tests/index.js" |
|
126 | commandLine "node", "tests/index.js" | |
| 118 | } |
|
127 | } | |
| 119 |
|
128 | |||
| 120 | assemble { |
|
129 | assemble { | |
| 121 | mustRunAfter sources.amd.output, |
|
130 | if (flavour == 'browser') { | |
| 122 |
sources. |
|
131 | dependsOn sources.amd.output | |
| 123 |
|
||||
| 124 | from sources.amd.output.compiledDir |
|
|||
| 125 | from sources.cjs.output.compiledDir |
|
|||
| 126 | } |
|
|||
| 127 |
|
||||
| 128 | assembleTest { |
|
|||
| 129 | mustRunAfter sources.amd.output, |
|
|||
| 130 | sources.cjs.output, |
|
|||
| 131 | sources.testAmd.output, |
|
|||
| 132 | sources.testCjs.output |
|
|||
| 133 |
|
||||
| 134 | from sources.amd.output.compiledDir |
|
132 | from sources.amd.output.compiledDir | |
|
|
133 | } | |||
|
|
134 | if (flavour == 'node') { | |||
|
|
135 | dependsOn sources.cjs.output | |||
| 135 | from sources.cjs.output.compiledDir |
|
136 | from sources.cjs.output.compiledDir | |
| 136 | from sources.testAmd.output.compiledDir |
|
|||
| 137 | from sources.testCjs.output.compiledDir |
|
|||
| 138 | } |
|
|||
| 139 |
|
||||
| 140 | task prepareLocalDebug { |
|
|||
| 141 | prepare.mustRunAfter it |
|
|||
| 142 |
|
||||
| 143 | doLast { |
|
|||
| 144 | tasks.matching{ it.name =~ /^configureTs/ }.configureEach { |
|
|||
| 145 | compilerOptions { |
|
|||
| 146 | sourceRoot = "file://" + it.rootDir |
|
|||
| 147 | } |
|
|||
| 148 | } |
|
|||
| 149 | } |
|
137 | } | |
| 150 | } |
|
138 | } | |
| 151 |
|
139 | |||
| 152 | task prepareNode { |
|
140 | assembleTest { | |
| 153 | prepare.mustRunAfter it |
|
141 | if (flavour == 'browser') { | |
|
|
142 | dependsOn sources.amd.output, sources.testAmd.output | |||
| 154 |
|
143 | |||
| 155 | doLast { |
|
144 | from sources.amd.output.compiledDir | |
| 156 | typescript { |
|
145 | from sources.testAmd.output.compiledDir | |
| 157 | compilerOptions { |
|
|||
| 158 | module = "commonjs" |
|
|||
| 159 | target = "es2017" |
|
|||
| 160 | lib = ["es2017", "dom", "scripthost"] |
|
|||
| 161 | } |
|
146 | } | |
| 162 | } |
|
147 | if (flavour == 'node') { | |
|
|
148 | dependsOn sources.cjs.output, sources.testCjs.output | |||
|
|
149 | ||||
|
|
150 | from sources.cjs.output.compiledDir | |||
|
|
151 | from sources.testCjs.output.compiledDir | |||
| 163 | } |
|
152 | } | |
| 164 | } |
|
153 | } | |
| 165 |
|
154 | |||
| 166 | task prepareBrowser { |
|
155 | task npmPackTypings(type: Copy) { | |
| 167 | prepare.mustRunAfter it |
|
156 | npmPack.dependsOn it | |
| 168 |
|
||||
| 169 | doLast { |
|
|||
| 170 | packageName = "@$npmScope/$project.name-amd" |
|
|||
| 171 |
|
||||
| 172 | typescript { |
|
|||
| 173 | compilerOptions { |
|
|||
| 174 | module = "amd" |
|
|||
| 175 | target = "es5" |
|
|||
| 176 | lib = ["es5", "dom", "scripthost", "es2015.promise", "es2015.symbol", "es2015.iterable"] |
|
|||
| 177 | } |
|
|||
| 178 | } |
|
|||
| 179 | } |
|
|||
| 180 | } |
|
|||
| 181 |
|
||||
| 182 | task npmPackTypingsAmd(type: Copy) { |
|
|||
| 183 | dependsOn sources.main.output |
|
157 | dependsOn sources.main.output | |
| 184 | dependsOn sources.amd.output |
|
|||
| 185 | npmPack.mustRunAfter it |
|
|||
| 186 |
|
158 | |||
| 187 | from sources.main.output.typingsDir |
|
159 | from sources.main.output.typingsDir | |
|
|
160 | ||||
|
|
161 | if (flavour == 'browser') { | |||
|
|
162 | dependsOn sources.amd.output | |||
| 188 | from sources.amd.output.typingsDir |
|
163 | from sources.amd.output.typingsDir | |
|
|
164 | } | |||
|
|
165 | if (flavour == 'node') { | |||
|
|
166 | dependsOn sources.cjs.output | |||
|
|
167 | from sources.cjs.output.typingsDir | |||
|
|
168 | } | |||
| 189 |
|
169 | |||
| 190 | into "${->buildDir}/npm/pack" |
|
170 | into "${->buildDir}/npm/pack" | |
| 191 | } |
|
171 | } | |
| 192 |
|
172 | |||
| 193 |
task npmPackSources |
|
173 | task npmPackSources(type: Copy) { | |
| 194 | from sources.main.ts |
|
174 | from sources.main.ts | |
|
|
175 | ||||
|
|
176 | if (flavour == 'browser') { | |||
| 195 | from sources.amd.ts |
|
177 | from sources.amd.ts | |
| 196 |
|
178 | } | ||
| 197 | npmPack.mustRunAfter it |
|
179 | if (flavour == 'node') { | |
|
|
180 | from sources.cjs.ts | |||
|
|
181 | } | |||
| 198 |
|
182 | |||
| 199 | into "${->buildDir}/npm/pack/_src" |
|
183 | into "${->buildDir}/npm/pack/_src" | |
| 200 | } |
|
184 | } | |
| 201 |
|
185 | |||
| 202 | task assembleBrowser { |
|
186 | if (symbols == 'pack') { | |
| 203 | dependsOn prepareBrowser, assemble, sources.amd.output |
|
187 | npmPack { | |
| 204 | } |
|
188 | dependsOn npmPackSources | |
| 205 |
|
||||
| 206 | task assembleNode { |
|
|||
| 207 | dependsOn prepareNode, assemble, sources.cjs.output |
|
|||
| 208 | } |
|
|||
| 209 |
|
||||
| 210 | task assembleTestBrowser { |
|
|||
| 211 | dependsOn prepareBrowser, prepareLocalDebug, assembleTest, sources.amd.output, sources.testAmd.output |
|
|||
| 212 | } |
|
189 | } | |
| 213 |
|
||||
| 214 | task testBrowser { |
|
|||
| 215 | dependsOn prepareBrowser, test, sources.amd.output, sources.testAmd.output |
|
|||
| 216 | } |
|
190 | } | |
| 217 |
|
191 | |||
| 218 | task testNode { |
|
|||
| 219 | dependsOn prepareNode, test, sources.cjs.output, sources.testCjs.output |
|
|||
| 220 | } |
|
|||
| 221 |
|
||||
| 222 | task npmPackBrowser { |
|
|||
| 223 | dependsOn assembleBrowser, npmPack, npmPackSourcesAmd, npmPackTypingsAmd |
|
|||
| 224 | } |
|
|||
| 225 |
|
||||
| 226 |
|
||||
| 227 | task packJsTar(type: Tar) { |
|
192 | task packJsTar(type: Tar) { | |
| 228 | dependsOn assemble; |
|
193 | dependsOn assemble; | |
| 229 |
|
194 | |||
| 230 | archiveBaseName = provider { packageName } |
|
195 | archiveBaseName = provider { packageName } | |
| 231 |
|
196 | |||
| 232 | destinationDirectory = buildDir |
|
197 | destinationDirectory = buildDir | |
| 233 | archiveClassifier = provider { typescript.compilerOptions.module } |
|
198 | archiveClassifier = provider { typescript.compilerOptions.module } | |
| 234 | compression = Compression.GZIP |
|
199 | compression = Compression.GZIP | |
| 235 |
|
200 | |||
| 236 | from(assemble.outputs) |
|
201 | from(assemble.outputs) | |
| 237 |
|
202 | |||
| 238 | doLast { |
|
203 | doLast { | |
| 239 | println archiveName; |
|
204 | println archiveName; | |
| 240 | } |
|
205 | } | |
| 241 | } |
|
206 | } | |
| 242 |
|
207 | |||
| 243 | task packTypingsTar(type: Tar) { |
|
208 | task packTypingsTar(type: Tar) { | |
| 244 | } |
|
209 | } | |
| 245 |
|
210 | |||
| 246 | publishing { |
|
211 | publishing { | |
| 247 | publications { |
|
212 | publications { | |
| 248 | local(IvyPublication) { |
|
213 | local(IvyPublication) { | |
| 249 | artifact(packJsTar) { |
|
214 | artifact(packJsTar) { | |
| 250 | type = "js" |
|
215 | type = "js" | |
| 251 | } |
|
216 | } | |
| 252 | } |
|
217 | } | |
| 253 | } |
|
218 | } | |
| 254 |
|
219 | |||
| 255 | repositories { |
|
220 | repositories { | |
| 256 | ivy { |
|
221 | ivy { | |
| 257 | url "ivy-repo" |
|
222 | url "ivy-repo" | |
| 258 | } |
|
223 | } | |
| 259 | } |
|
224 | } | |
| 260 | } No newline at end of file |
|
225 | } | |
| @@ -1,7 +1,9 | |||||
| 1 | group=org.implab |
|
1 | group=org.implab | |
| 2 | version= |
|
2 | version= | |
| 3 | author=Implab team |
|
3 | author=Implab team | |
| 4 | description=Dependency injection, logging, simple and fast text processing tools |
|
4 | description=Dependency injection, logging, simple and fast text processing tools | |
| 5 | license=BSD-2-Clause |
|
5 | license=BSD-2-Clause | |
| 6 | repository=https://bitbucket.org/implab/implabjs-core |
|
6 | repository=https://bitbucket.org/implab/implabjs-core | |
| 7 | npmScope=implab No newline at end of file |
|
7 | npmScope=implab | |
|
|
8 | flavour=browser | |||
|
|
9 | symbols=pack No newline at end of file | |||
| @@ -1,45 +1,45 | |||||
| 1 | import { Uuid } from "../Uuid"; |
|
1 | import { Uuid } from "../Uuid"; | |
| 2 | import { argumentNotEmptyString, getGlobal } from "../safe"; |
|
2 | import { argumentNotEmptyString, getGlobal } from "../safe"; | |
| 3 | import { TraceSource } from "../log/TraceSource"; |
|
3 | import { TraceSource } from "../log/TraceSource"; | |
| 4 | import m = require("module"); |
|
4 | import m = require("module"); | |
| 5 |
|
5 | |||
| 6 | const sandboxId = Uuid(); |
|
6 | const sandboxId = Uuid(); | |
| 7 | define(sandboxId, ["require"], r => r); |
|
7 | define(sandboxId, ["require"], (r: any) => r); | |
| 8 |
|
8 | |||
| 9 | const globalRequire = getGlobal().require as Require || requirejs; |
|
9 | const globalRequire = getGlobal().require as Require || requirejs; | |
| 10 |
|
10 | |||
| 11 | const trace = TraceSource.get(m.id); |
|
11 | const trace = TraceSource.get(m.id); | |
| 12 | trace.debug("globalRequire = {0}", globalRequire); |
|
12 | trace.debug("globalRequire = {0}", globalRequire); | |
| 13 |
|
13 | |||
| 14 | class ModuleResolver { |
|
14 | class ModuleResolver { | |
| 15 | _base: string; |
|
15 | _base: string; | |
| 16 | _require: Require; |
|
16 | _require: Require; | |
| 17 |
|
17 | |||
| 18 | constructor(req: Require, base?: string) { |
|
18 | constructor(req: Require, base?: string) { | |
| 19 | this._base = base; |
|
19 | this._base = base; | |
| 20 | this._require = req; |
|
20 | this._require = req; | |
| 21 | } |
|
21 | } | |
| 22 |
|
22 | |||
| 23 | resolve(moduleName: string) { |
|
23 | resolve(moduleName: string) { | |
| 24 | argumentNotEmptyString(moduleName, "moduleName"); |
|
24 | argumentNotEmptyString(moduleName, "moduleName"); | |
| 25 | const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName; |
|
25 | const resolvedName = moduleName[0] === "." && this._base ? [this._base, moduleName].join("/") : moduleName; | |
| 26 | trace.debug(`${moduleName} -> ${resolvedName}`); |
|
26 | trace.debug(`${moduleName} -> ${resolvedName}`); | |
| 27 |
|
27 | |||
| 28 | const req = this._require; |
|
28 | const req = this._require; | |
| 29 |
|
29 | |||
| 30 | return new Promise<any>((cb, eb) => { |
|
30 | return new Promise<any>((cb, eb) => { | |
| 31 | req([resolvedName], cb, eb); |
|
31 | req([resolvedName], cb, eb); | |
| 32 | }); |
|
32 | }); | |
| 33 | } |
|
33 | } | |
| 34 | } |
|
34 | } | |
| 35 |
|
35 | |||
| 36 | export function makeResolver(moduleName: string, contextRequire: Require) { |
|
36 | export function makeResolver(moduleName: string, contextRequire: Require) { | |
| 37 | const base = moduleName && moduleName.split("/").slice(0, -1).join("/"); |
|
37 | const base = moduleName && moduleName.split("/").slice(0, -1).join("/"); | |
| 38 |
|
38 | |||
| 39 | const req = contextRequire || globalRequire; |
|
39 | const req = contextRequire || globalRequire; | |
| 40 | if (!req) |
|
40 | if (!req) | |
| 41 | throw new Error("A global require isn't defined, the contextRequire parameter is mandatory"); |
|
41 | throw new Error("A global require isn't defined, the contextRequire parameter is mandatory"); | |
| 42 |
|
42 | |||
| 43 | const resolver = new ModuleResolver(req, base); |
|
43 | const resolver = new ModuleResolver(req, base); | |
| 44 | return (id: string) => resolver.resolve(id); |
|
44 | return (id: string) => resolver.resolve(id); | |
| 45 | } |
|
45 | } | |
General Comments 0
You need to be logged in to leave comments.
Login now
