Skip to content

Commit

Permalink
feat(worker): can import Build from @stencil/core
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Sep 2, 2020
1 parent 4529de7 commit 3058143
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/compiler/bundle/core-resolve-plugin.ts
Expand Up @@ -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');
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 3058143

Please sign in to comment.