From 30581437481f1375ee267c0e4387f40c66eefa7b Mon Sep 17 00:00:00 2001 From: "Manu Mtz.-Almeida" Date: Wed, 2 Sep 2020 17:01:11 +0200 Subject: [PATCH] feat(worker): can import Build from @stencil/core --- src/compiler/bundle/core-resolve-plugin.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/compiler/bundle/core-resolve-plugin.ts b/src/compiler/bundle/core-resolve-plugin.ts index d46e9dee8cc..ebfdeb92f63 100644 --- a/src/compiler/bundle/core-resolve-plugin.ts +++ b/src/compiler/bundle/core-resolve-plugin.ts @@ -16,17 +16,6 @@ import { import type { Plugin } from 'rollup'; export const coreResolvePlugin = (config: d.Config, compilerCtx: d.CompilerCtx, platform: 'client' | 'hydrate' | 'worker', externalRuntime: boolean): Plugin => { - if (platform === 'worker') { - return { - name: 'coreResolvePlugin', - resolveId(id) { - if (id === STENCIL_CORE_ID || id === STENCIL_INTERNAL_CLIENT_ID || id === STENCIL_INTERNAL_HYDRATE_ID) { - this.error(`${id} cannot be imported from a worker`); - } - return null; - }, - }; - } const compilerExe = config.sys.getCompilerExecutingPath(); const internalClient = getStencilInternalModule(config, compilerExe, 'client/index.js'); const internalClientPatchBrowser = getStencilInternalModule(config, compilerExe, 'client/patch-browser.js'); @@ -96,6 +85,15 @@ export const coreResolvePlugin = (config: d.Config, compilerCtx: d.CompilerCtx, filePath = normalizeFsPath(filePath); if (filePath === internalClient || filePath === internalHydrate) { + if (platform === 'worker') { + return ` +export const Build = { + isDev: false, + isBrowser: true, + isServer: false, + isTesting: false, +};`; + } let code = await compilerCtx.fs.readFile(filePath); if (typeof code !== 'string' && isRemoteUrl(compilerExe)) {