Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
alshdavid committed Aug 21, 2023
1 parent 65a6c06 commit 2ada1d4
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 1 deletion.
81 changes: 81 additions & 0 deletions packages/core/integration-tests/test/packager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import assert from 'assert';
import path from 'path';
import nullthrows from 'nullthrows';
import {normalizePath} from '@parcel/utils';
import {createWorkerFarm} from '@parcel/core';
import {md} from '@parcel/diagnostic';
import {
assertBundles,
bundle as _bundle,
bundler as _bundler,
distDir,
findAsset,
findDependency,
getNextBuild,
mergeParcelOptions,
outputFS,
overlayFS,
run,
runBundle,
} from '@parcel/test-utils';

const runBundler = (name, opts = {}) => {
return _bundle(
name,
// $FlowFixMe
mergeParcelOptions({}, opts),
);
};

const bundler = (name, opts = {}) => {
return _bundler(
name,
// $FlowFixMe
mergeParcelOptions({}, opts),
);
};

describe.only('packager', function () {
describe('globalThis polyfill', function () {
describe('es6', function () {
it('should include globalThis polyfill in ie11 builds', async function () {
const entryPoint = path.join(
__dirname,
'integration/html-js-dynamic/index.html',
);
const options = {
defaultTargetOptions: {
shouldOptimize: true,
engines: {
browsers: 'last 2 Chrome version',
node: '18',
},
},
};
const bundleGraph = await runBundler(entryPoint, options);

for (const b of bundleGraph.getBundles()) {
let code = await overlayFS.readFile(nullthrows(b.filePath), 'utf8');
console.log(b.name);
console.log(code);
console.log();
console.log();
}
});
});
});

// describe('commonjs', function () {
// it('supports require of commonjs modules', async function () {
// let b = await bundle(
// path.join(
// __dirname,
// '/integration/scope-hoisting/commonjs/require/a.js',
// ),
// );

// let output = await run(b);
// assert.equal(output, 2);
// });
// });
});
4 changes: 3 additions & 1 deletion packages/core/test-utils/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export function getParcelOptions(
entries: FilePath | Array<FilePath>,
opts?: $Shape<InitialParcelOptions>,
): InitialParcelOptions {
return mergeParcelOptions(
const o = mergeParcelOptions(
{
entries,
shouldDisableCache: true,
Expand All @@ -133,6 +133,8 @@ export function getParcelOptions(
},
opts,
);
console.log(o);
return o;
}

export function bundler(
Expand Down
2 changes: 2 additions & 0 deletions packages/packagers/js/src/ScopeHoistingPackager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,8 @@ ${code}
this.usedHelpers.add('$parcel$global');
}

console.log('um', this.bundle.env.supports('global-this'));

for (let helper of this.usedHelpers) {
let currentHelper = helpers[helper];
if (typeof currentHelper === 'function') {
Expand Down

0 comments on commit 2ada1d4

Please sign in to comment.