@embroider/webpack 3.1.3 → 3.1.4-unstable.0e00f2b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/webpack",
3
- "version": "3.1.3",
3
+ "version": "3.1.4-unstable.0e00f2b",
4
4
  "private": false,
5
5
  "description": "Builds EmberJS apps with Webpack",
6
6
  "repository": {
@@ -16,8 +16,12 @@
16
16
  "src/**/*.d.ts",
17
17
  "src/**/*.js.map"
18
18
  ],
19
+ "scripts": {},
19
20
  "dependencies": {
20
21
  "@babel/core": "^7.14.5",
22
+ "@embroider/babel-loader-8": "3.0.1-unstable.0e00f2b",
23
+ "@embroider/hbs-loader": "3.0.2-unstable.0e00f2b",
24
+ "@embroider/shared-internals": "2.2.4-unstable.0e00f2b",
21
25
  "@types/supports-color": "^8.1.0",
22
26
  "assert-never": "^1.2.1",
23
27
  "babel-loader": "^8.2.2",
@@ -35,12 +39,10 @@
35
39
  "style-loader": "^2.0.0",
36
40
  "supports-color": "^8.1.0",
37
41
  "terser": "^5.7.0",
38
- "thread-loader": "^3.0.4",
39
- "@embroider/babel-loader-8": "3.0.0",
40
- "@embroider/shared-internals": "2.2.3",
41
- "@embroider/hbs-loader": "3.0.1"
42
+ "thread-loader": "^3.0.4"
42
43
  },
43
44
  "devDependencies": {
45
+ "@embroider/core": "3.1.4-unstable.0e00f2b",
44
46
  "@types/csso": "^3.5.1",
45
47
  "@types/debug": "^4.1.5",
46
48
  "@types/fs-extra": "^9.0.12",
@@ -52,14 +54,13 @@
52
54
  "webpack": "^5.38.1"
53
55
  },
54
56
  "peerDependencies": {
55
- "webpack": "^5.0.0",
56
- "@embroider/core": "^3.1.3"
57
+ "@embroider/core": "3.1.4-unstable.0e00f2b",
58
+ "webpack": "^5.0.0"
57
59
  },
58
60
  "engines": {
59
61
  "node": "12.* || 14.* || >= 16"
60
62
  },
61
63
  "volta": {
62
64
  "extends": "../../package.json"
63
- },
64
- "scripts": {}
65
- }
65
+ }
66
+ }
@@ -1,11 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const core_1 = require("@embroider/core");
4
+ let resolverLoader;
5
+ function setup(appRoot) {
6
+ if ((resolverLoader === null || resolverLoader === void 0 ? void 0 : resolverLoader.appRoot) !== appRoot) {
7
+ resolverLoader = new core_1.ResolverLoader(appRoot);
8
+ }
9
+ return resolverLoader;
10
+ }
4
11
  function virtualLoader() {
5
12
  if (typeof this.query === 'string' && this.query[0] === '?') {
6
- let filename = this.query.slice(1);
13
+ let params = new URLSearchParams(this.query);
14
+ let filename = params.get('f');
15
+ let appRoot = params.get('a');
16
+ if (!filename || !appRoot) {
17
+ throw new Error(`bug in @embroider/webpack virtual loader, cannot locate params in ${this.query}`);
18
+ }
19
+ let { resolver } = setup(appRoot);
7
20
  this.resourcePath = filename;
8
- return (0, core_1.virtualContent)(filename);
21
+ return (0, core_1.virtualContent)(filename, resolver);
9
22
  }
10
23
  throw new Error(`@embroider/webpack/src/virtual-loader received unexpected request: ${this.query}`);
11
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-loader.js","sourceRoot":"","sources":["virtual-loader.ts"],"names":[],"mappings":";;AAAA,0CAAiD;AAGjD,SAAwB,aAAa;IACnC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAC3D,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,OAAO,IAAA,qBAAc,EAAC,QAAQ,CAAC,CAAC;KACjC;IACD,MAAM,IAAI,KAAK,CAAC,sEAAsE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AACtG,CAAC;AAPD,gCAOC","sourcesContent":["import { virtualContent } from '@embroider/core';\nimport { LoaderContext } from 'webpack';\n\nexport default function virtualLoader(this: LoaderContext<unknown>) {\n if (typeof this.query === 'string' && this.query[0] === '?') {\n let filename = this.query.slice(1);\n this.resourcePath = filename;\n return virtualContent(filename);\n }\n throw new Error(`@embroider/webpack/src/virtual-loader received unexpected request: ${this.query}`);\n}\n"]}
1
+ {"version":3,"file":"virtual-loader.js","sourceRoot":"","sources":["virtual-loader.ts"],"names":[],"mappings":";;AAAA,0CAAiE;AAGjE,IAAI,cAA0C,CAAC;AAE/C,SAAS,KAAK,CAAC,OAAe;IAC5B,IAAI,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,MAAK,OAAO,EAAE;QACvC,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,CAAC;KAC9C;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAwB,aAAa;IACnC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QAC3D,IAAI,MAAM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAI,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,qEAAqE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SACpG;QACD,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,OAAO,IAAA,qBAAc,EAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;KAC3C;IACD,MAAM,IAAI,KAAK,CAAC,sEAAsE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;AACtG,CAAC;AAbD,gCAaC","sourcesContent":["import { ResolverLoader, virtualContent } from '@embroider/core';\nimport { LoaderContext } from 'webpack';\n\nlet resolverLoader: ResolverLoader | undefined;\n\nfunction setup(appRoot: string): ResolverLoader {\n if (resolverLoader?.appRoot !== appRoot) {\n resolverLoader = new ResolverLoader(appRoot);\n }\n return resolverLoader;\n}\n\nexport default function virtualLoader(this: LoaderContext<unknown>) {\n if (typeof this.query === 'string' && this.query[0] === '?') {\n let params = new URLSearchParams(this.query);\n let filename = params.get('f');\n let appRoot = params.get('a');\n if (!filename || !appRoot) {\n throw new Error(`bug in @embroider/webpack virtual loader, cannot locate params in ${this.query}`);\n }\n let { resolver } = setup(appRoot);\n this.resourcePath = filename;\n return virtualContent(filename, resolver);\n }\n throw new Error(`@embroider/webpack/src/virtual-loader received unexpected request: ${this.query}`);\n}\n"]}
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
- var _EmbroiderPlugin_instances, _EmbroiderPlugin_resolver, _EmbroiderPlugin_babelLoaderPrefix, _EmbroiderPlugin_addLoaderAlias;
16
+ var _EmbroiderPlugin_instances, _EmbroiderPlugin_resolver, _EmbroiderPlugin_babelLoaderPrefix, _EmbroiderPlugin_appRoot, _EmbroiderPlugin_addLoaderAlias;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.EmbroiderPlugin = void 0;
19
19
  const path_1 = require("path");
@@ -22,14 +22,16 @@ const assert_never_1 = __importDefault(require("assert-never"));
22
22
  const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
23
23
  const virtualLoaderName = '@embroider/webpack/src/virtual-loader';
24
24
  const virtualLoaderPath = (0, path_1.resolve)(__dirname, './virtual-loader.js');
25
- const virtualRequestPattern = new RegExp(`${(0, escape_string_regexp_1.default)(virtualLoaderPath)}\\?(?<filename>.+)!`);
25
+ const virtualRequestPattern = new RegExp(`${(0, escape_string_regexp_1.default)(virtualLoaderPath)}\\?(?<query>.+)!`);
26
26
  class EmbroiderPlugin {
27
27
  constructor(opts, babelLoaderPrefix) {
28
28
  _EmbroiderPlugin_instances.add(this);
29
29
  _EmbroiderPlugin_resolver.set(this, void 0);
30
30
  _EmbroiderPlugin_babelLoaderPrefix.set(this, void 0);
31
+ _EmbroiderPlugin_appRoot.set(this, void 0);
31
32
  __classPrivateFieldSet(this, _EmbroiderPlugin_resolver, new core_1.Resolver(opts), "f");
32
33
  __classPrivateFieldSet(this, _EmbroiderPlugin_babelLoaderPrefix, babelLoaderPrefix, "f");
34
+ __classPrivateFieldSet(this, _EmbroiderPlugin_appRoot, opts.appRoot, "f");
33
35
  }
34
36
  apply(compiler) {
35
37
  __classPrivateFieldGet(this, _EmbroiderPlugin_instances, "m", _EmbroiderPlugin_addLoaderAlias).call(this, compiler, virtualLoaderName, virtualLoaderPath);
@@ -37,7 +39,7 @@ class EmbroiderPlugin {
37
39
  let defaultResolve = getDefaultResolveHook(nmf.hooks.resolve.taps);
38
40
  let adaptedResolve = getAdaptedResolve(defaultResolve);
39
41
  nmf.hooks.resolve.tapAsync({ name: '@embroider/webpack', stage: 50 }, (state, callback) => {
40
- let request = WebpackModuleRequest.from(state, __classPrivateFieldGet(this, _EmbroiderPlugin_babelLoaderPrefix, "f"));
42
+ let request = WebpackModuleRequest.from(state, __classPrivateFieldGet(this, _EmbroiderPlugin_babelLoaderPrefix, "f"), __classPrivateFieldGet(this, _EmbroiderPlugin_appRoot, "f"));
41
43
  if (!request) {
42
44
  defaultResolve(state, callback);
43
45
  return;
@@ -59,7 +61,7 @@ class EmbroiderPlugin {
59
61
  }
60
62
  }
61
63
  exports.EmbroiderPlugin = EmbroiderPlugin;
62
- _EmbroiderPlugin_resolver = new WeakMap(), _EmbroiderPlugin_babelLoaderPrefix = new WeakMap(), _EmbroiderPlugin_instances = new WeakSet(), _EmbroiderPlugin_addLoaderAlias = function _EmbroiderPlugin_addLoaderAlias(compiler, name, alias) {
64
+ _EmbroiderPlugin_resolver = new WeakMap(), _EmbroiderPlugin_babelLoaderPrefix = new WeakMap(), _EmbroiderPlugin_appRoot = new WeakMap(), _EmbroiderPlugin_instances = new WeakSet(), _EmbroiderPlugin_addLoaderAlias = function _EmbroiderPlugin_addLoaderAlias(compiler, name, alias) {
63
65
  let { resolveLoader } = compiler.options;
64
66
  if (Array.isArray(resolveLoader.alias)) {
65
67
  resolveLoader.alias.push({ name, alias });
@@ -101,7 +103,7 @@ function getAdaptedResolve(defaultResolve) {
101
103
  };
102
104
  }
103
105
  class WebpackModuleRequest {
104
- static from(state, babelLoaderPrefix) {
106
+ static from(state, babelLoaderPrefix, appRoot) {
105
107
  var _a, _b, _c;
106
108
  // when the files emitted from our virtual-loader try to import things,
107
109
  // those requests show in webpack as having no issuer. But we can see here
@@ -111,7 +113,7 @@ class WebpackModuleRequest {
111
113
  for (let dep of state.dependencies) {
112
114
  let match = virtualRequestPattern.exec((_b = dep._parentModule) === null || _b === void 0 ? void 0 : _b.userRequest);
113
115
  if (match) {
114
- state.contextInfo.issuer = match.groups.filename;
116
+ state.contextInfo.issuer = new URLSearchParams(match.groups.query).get('f');
115
117
  state.context = (0, path_1.dirname)(state.contextInfo.issuer);
116
118
  }
117
119
  }
@@ -123,11 +125,12 @@ class WebpackModuleRequest {
123
125
  !state.request.includes(virtualLoaderName) && // prevents recursion on requests we have already sent to our virtual loader
124
126
  !state.request.startsWith('!') // ignores internal webpack resolvers
125
127
  ) {
126
- return new WebpackModuleRequest(babelLoaderPrefix, state);
128
+ return new WebpackModuleRequest(babelLoaderPrefix, appRoot, state);
127
129
  }
128
130
  }
129
- constructor(babelLoaderPrefix, state, isVirtual = false) {
131
+ constructor(babelLoaderPrefix, appRoot, state, isVirtual = false) {
130
132
  this.babelLoaderPrefix = babelLoaderPrefix;
133
+ this.appRoot = appRoot;
131
134
  this.state = state;
132
135
  this.isVirtual = isVirtual;
133
136
  // these get copied here because we mutate the underlying state as we
@@ -137,10 +140,11 @@ class WebpackModuleRequest {
137
140
  // that can actually be handed back to webpack)
138
141
  this.specifier = state.request;
139
142
  this.fromFile = state.contextInfo.issuer;
143
+ this.meta = state.contextInfo._embroiderMeta ? { ...state.contextInfo._embroiderMeta } : undefined;
140
144
  }
141
145
  alias(newSpecifier) {
142
146
  this.state.request = newSpecifier;
143
- return new WebpackModuleRequest(this.babelLoaderPrefix, this.state);
147
+ return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state);
144
148
  }
145
149
  rehome(newFromFile) {
146
150
  if (this.fromFile === newFromFile) {
@@ -149,13 +153,20 @@ class WebpackModuleRequest {
149
153
  else {
150
154
  this.state.contextInfo.issuer = newFromFile;
151
155
  this.state.context = (0, path_1.dirname)(newFromFile);
152
- return new WebpackModuleRequest(this.babelLoaderPrefix, this.state);
156
+ return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state);
153
157
  }
154
158
  }
155
159
  virtualize(filename) {
156
- let next = this.alias(`${this.babelLoaderPrefix}${virtualLoaderName}?${filename}!`);
160
+ let params = new URLSearchParams();
161
+ params.set('f', filename);
162
+ params.set('a', this.appRoot);
163
+ let next = this.alias(`${this.babelLoaderPrefix}${virtualLoaderName}?${params.toString()}!`);
157
164
  next.isVirtual = true;
158
165
  return next;
159
166
  }
167
+ withMeta(meta) {
168
+ this.state.contextInfo._embroiderMeta = meta;
169
+ return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state);
170
+ }
160
171
  }
161
172
  //# sourceMappingURL=webpack-resolver-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-resolver-plugin.js","sourceRoot":"","sources":["webpack-resolver-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAwC;AACxC,0CAMyB;AAEzB,gEAAuC;AACvC,gFAAgD;AAIhD,MAAM,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CAAC;IACD,UAAU,CAAC,QAAgB;QACzB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,IAAI,QAAQ,GAAG,CAAC,CAAC;QACpF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { dirname, resolve } from 'path';\nimport {\n Resolver as EmbroiderResolver,\n ResolverOptions as EmbroiderResolverOptions,\n ModuleRequest,\n ResolverFunction,\n Resolution,\n} from '@embroider/core';\nimport type { Compiler, Module } from 'webpack';\nimport assertNever from 'assert-never';\nimport escapeRegExp from 'escape-string-regexp';\n\nexport { EmbroiderResolverOptions as Options };\n\nconst virtualLoaderName = '@embroider/webpack/src/virtual-loader';\nconst virtualLoaderPath = resolve(__dirname, './virtual-loader.js');\nconst virtualRequestPattern = new RegExp(`${escapeRegExp(virtualLoaderPath)}\\\\?(?<filename>.+)!`);\n\nexport class EmbroiderPlugin {\n #resolver: EmbroiderResolver;\n #babelLoaderPrefix: string;\n\n constructor(opts: EmbroiderResolverOptions, babelLoaderPrefix: string) {\n this.#resolver = new EmbroiderResolver(opts);\n this.#babelLoaderPrefix = babelLoaderPrefix;\n }\n\n #addLoaderAlias(compiler: Compiler, name: string, alias: string) {\n let { resolveLoader } = compiler.options;\n if (Array.isArray(resolveLoader.alias)) {\n resolveLoader.alias.push({ name, alias });\n } else if (resolveLoader.alias) {\n resolveLoader.alias[name] = alias;\n } else {\n resolveLoader.alias = {\n [name]: alias,\n };\n }\n }\n\n apply(compiler: Compiler) {\n this.#addLoaderAlias(compiler, virtualLoaderName, virtualLoaderPath);\n\n compiler.hooks.normalModuleFactory.tap('@embroider/webpack', nmf => {\n let defaultResolve = getDefaultResolveHook(nmf.hooks.resolve.taps);\n let adaptedResolve = getAdaptedResolve(defaultResolve);\n\n nmf.hooks.resolve.tapAsync({ name: '@embroider/webpack', stage: 50 }, (state: unknown, callback: CB) => {\n let request = WebpackModuleRequest.from(state, this.#babelLoaderPrefix);\n if (!request) {\n defaultResolve(state, callback);\n return;\n }\n\n this.#resolver.resolve(request, adaptedResolve).then(\n resolution => {\n switch (resolution.type) {\n case 'not_found':\n callback(resolution.err);\n break;\n case 'found':\n callback(null, resolution.result);\n break;\n default:\n throw assertNever(resolution);\n }\n },\n err => callback(err)\n );\n });\n });\n }\n}\n\ntype CB = (err: null | Error, result?: Module | undefined) => void;\ntype DefaultResolve = (state: unknown, callback: CB) => void;\n\n// Despite being absolutely riddled with way-too-powerful tap points,\n// webpack still doesn't succeed in making it possible to provide a\n// fallback to the default resolve hook in the NormalModuleFactory. So\n// instead we will find the default behavior and call it from our own tap,\n// giving us a chance to handle its failures.\nfunction getDefaultResolveHook(taps: { name: string; fn: Function }[]): DefaultResolve {\n let { fn } = taps.find(t => t.name === 'NormalModuleFactory')!;\n return fn as DefaultResolve;\n}\n\n// This converts the raw function we got out of webpack into the right interface\n// for use by @embroider/core's resolver.\nfunction getAdaptedResolve(\n defaultResolve: DefaultResolve\n): ResolverFunction<WebpackModuleRequest, Resolution<Module, null | Error>> {\n return function (request: WebpackModuleRequest): Promise<Resolution<Module, null | Error>> {\n return new Promise(resolve => {\n defaultResolve(request.state, (err, value) => {\n if (err) {\n // unfortunately webpack doesn't let us distinguish between Not Found\n // and other unexpected exceptions here.\n resolve({ type: 'not_found', err });\n } else {\n resolve({ type: 'found', result: value! });\n }\n });\n });\n };\n}\n\nclass WebpackModuleRequest implements ModuleRequest {\n specifier: string;\n fromFile: string;\n\n static from(state: any, babelLoaderPrefix: string): WebpackModuleRequest | undefined {\n // when the files emitted from our virtual-loader try to import things,\n // those requests show in webpack as having no issuer. But we can see here\n // which requests they are and adjust the issuer so they resolve things from\n // the correct logical place.\n if (!state.contextInfo?.issuer && Array.isArray(state.dependencies)) {\n for (let dep of state.dependencies) {\n let match = virtualRequestPattern.exec(dep._parentModule?.userRequest);\n if (match) {\n state.contextInfo.issuer = match.groups!.filename;\n state.context = dirname(state.contextInfo.issuer);\n }\n }\n }\n\n if (\n typeof state.request === 'string' &&\n typeof state.context === 'string' &&\n typeof state.contextInfo?.issuer === 'string' &&\n state.contextInfo.issuer !== '' &&\n !state.request.includes(virtualLoaderName) && // prevents recursion on requests we have already sent to our virtual loader\n !state.request.startsWith('!') // ignores internal webpack resolvers\n ) {\n return new WebpackModuleRequest(babelLoaderPrefix, state);\n }\n }\n\n constructor(\n private babelLoaderPrefix: string,\n public state: {\n request: string;\n context: string;\n contextInfo: {\n issuer: string;\n };\n },\n public isVirtual = false\n ) {\n // these get copied here because we mutate the underlying state as we\n // convert one request into the next, and it seems better for debuggability\n // if the fields on the previous request don't change when you make a new\n // one (although it is true that only the newest one has a a valid `state`\n // that can actually be handed back to webpack)\n this.specifier = state.request;\n this.fromFile = state.contextInfo.issuer;\n }\n\n alias(newSpecifier: string) {\n this.state.request = newSpecifier;\n return new WebpackModuleRequest(this.babelLoaderPrefix, this.state) as this;\n }\n rehome(newFromFile: string) {\n if (this.fromFile === newFromFile) {\n return this;\n } else {\n this.state.contextInfo.issuer = newFromFile;\n this.state.context = dirname(newFromFile);\n return new WebpackModuleRequest(this.babelLoaderPrefix, this.state) as this;\n }\n }\n virtualize(filename: string) {\n let next = this.alias(`${this.babelLoaderPrefix}${virtualLoaderName}?${filename}!`);\n next.isVirtual = true;\n return next;\n }\n}\n"]}
1
+ {"version":3,"file":"webpack-resolver-plugin.js","sourceRoot":"","sources":["webpack-resolver-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAwC;AACxC,0CAMyB;AAEzB,gEAAuC;AACvC,gFAAgD;AAIhD,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AAClE,MAAM,iBAAiB,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;AACpE,MAAM,qBAAqB,GAAG,IAAI,MAAM,CAAC,GAAG,IAAA,8BAAY,EAAC,iBAAiB,CAAC,kBAA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,GAAG,WAAW,CAAC;YAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC;YAC1C,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAS,CAAC;SAC3F;IACH,CAAC;IACD,UAAU,CAAC,QAAgB;QACzB,IAAI,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC1B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,IAAI,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7F,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,QAAQ,CAAC,IAAqC;QAC5C,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,GAAG,IAAI,CAAC;QAC7C,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAS,CAAC;IAC5F,CAAC;CACF","sourcesContent":["import { dirname, resolve } from 'path';\nimport {\n Resolver as EmbroiderResolver,\n ResolverOptions as EmbroiderResolverOptions,\n ModuleRequest,\n ResolverFunction,\n Resolution,\n} from '@embroider/core';\nimport type { Compiler, Module } from 'webpack';\nimport assertNever from 'assert-never';\nimport escapeRegExp from 'escape-string-regexp';\n\nexport { EmbroiderResolverOptions as Options };\n\nconst virtualLoaderName = '@embroider/webpack/src/virtual-loader';\nconst virtualLoaderPath = resolve(__dirname, './virtual-loader.js');\nconst virtualRequestPattern = new RegExp(`${escapeRegExp(virtualLoaderPath)}\\\\?(?<query>.+)!`);\n\nexport class EmbroiderPlugin {\n #resolver: EmbroiderResolver;\n #babelLoaderPrefix: string;\n #appRoot: string;\n\n constructor(opts: EmbroiderResolverOptions, babelLoaderPrefix: string) {\n this.#resolver = new EmbroiderResolver(opts);\n this.#babelLoaderPrefix = babelLoaderPrefix;\n this.#appRoot = opts.appRoot;\n }\n\n #addLoaderAlias(compiler: Compiler, name: string, alias: string) {\n let { resolveLoader } = compiler.options;\n if (Array.isArray(resolveLoader.alias)) {\n resolveLoader.alias.push({ name, alias });\n } else if (resolveLoader.alias) {\n resolveLoader.alias[name] = alias;\n } else {\n resolveLoader.alias = {\n [name]: alias,\n };\n }\n }\n\n apply(compiler: Compiler) {\n this.#addLoaderAlias(compiler, virtualLoaderName, virtualLoaderPath);\n\n compiler.hooks.normalModuleFactory.tap('@embroider/webpack', nmf => {\n let defaultResolve = getDefaultResolveHook(nmf.hooks.resolve.taps);\n let adaptedResolve = getAdaptedResolve(defaultResolve);\n\n nmf.hooks.resolve.tapAsync({ name: '@embroider/webpack', stage: 50 }, (state: unknown, callback: CB) => {\n let request = WebpackModuleRequest.from(state, this.#babelLoaderPrefix, this.#appRoot);\n if (!request) {\n defaultResolve(state, callback);\n return;\n }\n\n this.#resolver.resolve(request, adaptedResolve).then(\n resolution => {\n switch (resolution.type) {\n case 'not_found':\n callback(resolution.err);\n break;\n case 'found':\n callback(null, resolution.result);\n break;\n default:\n throw assertNever(resolution);\n }\n },\n err => callback(err)\n );\n });\n });\n }\n}\n\ntype CB = (err: null | Error, result?: Module | undefined) => void;\ntype DefaultResolve = (state: unknown, callback: CB) => void;\n\n// Despite being absolutely riddled with way-too-powerful tap points,\n// webpack still doesn't succeed in making it possible to provide a\n// fallback to the default resolve hook in the NormalModuleFactory. So\n// instead we will find the default behavior and call it from our own tap,\n// giving us a chance to handle its failures.\nfunction getDefaultResolveHook(taps: { name: string; fn: Function }[]): DefaultResolve {\n let { fn } = taps.find(t => t.name === 'NormalModuleFactory')!;\n return fn as DefaultResolve;\n}\n\n// This converts the raw function we got out of webpack into the right interface\n// for use by @embroider/core's resolver.\nfunction getAdaptedResolve(\n defaultResolve: DefaultResolve\n): ResolverFunction<WebpackModuleRequest, Resolution<Module, null | Error>> {\n return function (request: WebpackModuleRequest): Promise<Resolution<Module, null | Error>> {\n return new Promise(resolve => {\n defaultResolve(request.state, (err, value) => {\n if (err) {\n // unfortunately webpack doesn't let us distinguish between Not Found\n // and other unexpected exceptions here.\n resolve({ type: 'not_found', err });\n } else {\n resolve({ type: 'found', result: value! });\n }\n });\n });\n };\n}\n\nclass WebpackModuleRequest implements ModuleRequest {\n readonly specifier: string;\n readonly fromFile: string;\n readonly meta: Record<string, any> | undefined;\n\n static from(state: any, babelLoaderPrefix: string, appRoot: string): WebpackModuleRequest | undefined {\n // when the files emitted from our virtual-loader try to import things,\n // those requests show in webpack as having no issuer. But we can see here\n // which requests they are and adjust the issuer so they resolve things from\n // the correct logical place.\n if (!state.contextInfo?.issuer && Array.isArray(state.dependencies)) {\n for (let dep of state.dependencies) {\n let match = virtualRequestPattern.exec(dep._parentModule?.userRequest);\n if (match) {\n state.contextInfo.issuer = new URLSearchParams(match.groups!.query).get('f');\n state.context = dirname(state.contextInfo.issuer);\n }\n }\n }\n\n if (\n typeof state.request === 'string' &&\n typeof state.context === 'string' &&\n typeof state.contextInfo?.issuer === 'string' &&\n state.contextInfo.issuer !== '' &&\n !state.request.includes(virtualLoaderName) && // prevents recursion on requests we have already sent to our virtual loader\n !state.request.startsWith('!') // ignores internal webpack resolvers\n ) {\n return new WebpackModuleRequest(babelLoaderPrefix, appRoot, state);\n }\n }\n\n constructor(\n private babelLoaderPrefix: string,\n private appRoot: string,\n public state: {\n request: string;\n context: string;\n contextInfo: {\n issuer: string;\n _embroiderMeta?: Record<string, any> | undefined;\n };\n },\n public isVirtual = false\n ) {\n // these get copied here because we mutate the underlying state as we\n // convert one request into the next, and it seems better for debuggability\n // if the fields on the previous request don't change when you make a new\n // one (although it is true that only the newest one has a a valid `state`\n // that can actually be handed back to webpack)\n this.specifier = state.request;\n this.fromFile = state.contextInfo.issuer;\n this.meta = state.contextInfo._embroiderMeta ? { ...state.contextInfo._embroiderMeta } : undefined;\n }\n\n alias(newSpecifier: string) {\n this.state.request = newSpecifier;\n return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state) as this;\n }\n rehome(newFromFile: string) {\n if (this.fromFile === newFromFile) {\n return this;\n } else {\n this.state.contextInfo.issuer = newFromFile;\n this.state.context = dirname(newFromFile);\n return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state) as this;\n }\n }\n virtualize(filename: string) {\n let params = new URLSearchParams();\n params.set('f', filename);\n params.set('a', this.appRoot);\n let next = this.alias(`${this.babelLoaderPrefix}${virtualLoaderName}?${params.toString()}!`);\n next.isVirtual = true;\n return next;\n }\n withMeta(meta: Record<string, any> | undefined): this {\n this.state.contextInfo._embroiderMeta = meta;\n return new WebpackModuleRequest(this.babelLoaderPrefix, this.appRoot, this.state) as this;\n }\n}\n"]}
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Edward Faulkner
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.