Skip to content

Commit

Permalink
Fix importing ES Modules from our other repositories (#1770)
Browse files Browse the repository at this point in the history
This change should finally get importing ES Modules from our other
repositories working, which also means we can drop the final
shared/content-scope-scripts copy build step.
  • Loading branch information
kzar committed Mar 9, 2023
1 parent 1947789 commit 2cab7b5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ITEMS := shared/html shared/data shared/img
###--- Binaries ---###
SASS = node_modules/.bin/sass
BROWSERIFY_BIN = node_modules/.bin/browserify
BROWSERIFY = $(BROWSERIFY_BIN) -t babelify
BROWSERIFY = $(BROWSERIFY_BIN) -t babelify -t [ babelify --global --only [ ./node_modules/@duckduckgo ] --presets [ @babel/preset-env ] ]
ifeq ($(type),dev)
BROWSERIFY += -d
endif
Expand Down Expand Up @@ -37,17 +37,11 @@ watch:
unit-test: build/test/background.js build/test/ui.js build/test/shared-utils.js
$(KARMA) start karma.conf.js

shared/content-scope-scripts: node_modules/@duckduckgo/content-scope-scripts $(shell find node_modules/@duckduckgo/content-scope-scripts/src -type f)
rsync -a node_modules/@duckduckgo/content-scope-scripts/ shared/content-scope-scripts --include="lib/***" --include="src/***" --exclude="*"

shared/content-scope-scripts/lib/%: shared/content-scope-scripts
shared/content-scope-scripts/src/%: shared/content-scope-scripts

.PHONY: unit-test

## Build unit-tests with browserify
UNIT_TEST_SRC = unit-test/background/*.js unit-test/background/classes/*.js unit-test/background/events/*.js unit-test/background/storage/*.js unit-test/background/reference-tests/*.js
build/test/background.js: $(TEST_FILES) $(SOURCE_FILES) shared/content-scope-scripts
build/test/background.js: $(TEST_FILES) $(SOURCE_FILES)
mkdir -p `dirname $@`
$(BROWSERIFY) -t brfs -t ./scripts/browserifyFileMapTransform $(UNIT_TEST_SRC) -o $@

Expand Down Expand Up @@ -132,7 +126,6 @@ integration-test/artifacts/attribution.json: node_modules/privacy-test-pages/adC
clean:
rm -f shared/data/smarter_encryption.txt shared/data/bundled/smarter-encryption-rules.json integration-test/artifacts/attribution.json:
rm -rf $(BUILD_DIR)
rm -rf unit-test/data/reference-tests shared/content-scope-scripts


###--- Copy targets ---###
Expand Down
2 changes: 1 addition & 1 deletion unit-test/background/reference-tests/3p-cookies-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const getArgumentsObject = require('../../../shared/js/background/helpers/argume

const jsdom = require('jsdom')

const trackingJsCookieProtection = require('../../../shared/content-scope-scripts/src/features/cookie')
const trackingJsCookieProtection = require('@duckduckgo/content-scope-scripts/src/features/cookie')

const trackingConfigReference = require('@duckduckgo/privacy-reference-tests/block-third-party-tracking-cookies/config_reference.json')
const trackingBlocklistReference = require('@duckduckgo/privacy-reference-tests/block-third-party-tracking-cookies/tracker_radar_reference.json')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ for (const setName of Object.keys(testSets)) {
// eslint-disable-next-line no-global-assign
globalThis = jsdomWindow

const utils = require('../../../shared/content-scope-scripts/src/utils')
const utils = require('@duckduckgo/content-scope-scripts/src/utils')
utils.setGlobal(jsdomWindow)

const jsCookieProtection = require('../../../shared/content-scope-scripts/src/features/cookie')
const jsCookieProtection = require('@duckduckgo/content-scope-scripts/src/features/cookie')

jsCookieProtection.load({
platform: constants.platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const tabManager = require('../../../shared/js/background/tab-manager')
const browserWrapper = require('../../../shared/js/background/wrapper')
const getArgumentsObject = require('../../../shared/js/background/helpers/arguments-object')

const batteryProtection = require('../../../shared/content-scope-scripts/src/features/fingerprinting-battery')
const hardwareProtection = require('../../../shared/content-scope-scripts/src/features/fingerprinting-hardware')
const screenProtection = require('../../../shared/content-scope-scripts/src/features/fingerprinting-screen-size')
const tempStorageProtection = require('../../../shared/content-scope-scripts/src/features/fingerprinting-temporary-storage')
const { isFeatureBroken } = require('../../../shared/content-scope-scripts/src/utils')
const batteryProtection = require('@duckduckgo/content-scope-scripts/src/features/fingerprinting-battery')
const hardwareProtection = require('@duckduckgo/content-scope-scripts/src/features/fingerprinting-hardware')
const screenProtection = require('@duckduckgo/content-scope-scripts/src/features/fingerprinting-screen-size')
const tempStorageProtection = require('@duckduckgo/content-scope-scripts/src/features/fingerprinting-temporary-storage')
const { isFeatureBroken } = require('@duckduckgo/content-scope-scripts/src/utils')

const configReference = require('@duckduckgo/privacy-reference-tests/fingerprinting-protections/config_reference.json')
const testSets = require('@duckduckgo/privacy-reference-tests/fingerprinting-protections/tests.json')
Expand Down
4 changes: 2 additions & 2 deletions unit-test/background/reference-tests/gpc-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const tdsStorage = require('../../../shared/js/background/storage/tds')

const Site = require('../../../shared/js/background/classes/site')
const GPC = require('../../../shared/js/background/GPC')
const gpcContentScript = require('../../../shared/content-scope-scripts/src/features/gpc')
const gpcContentScript = require('@duckduckgo/content-scope-scripts/src/features/gpc')
const browserWrapper = require('../../../shared/js/background/wrapper')
const settings = require('../../../shared/js/background/settings')

const contentScriptUtils = require('../../../shared/content-scope-scripts/src/utils.js')
const contentScriptUtils = require('@duckduckgo/content-scope-scripts/src/utils.js')

const testSets = require('@duckduckgo/privacy-reference-tests/global-privacy-control/tests.json')
const config = require('@duckduckgo/privacy-reference-tests/global-privacy-control/config_reference.json')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const Site = require('../../../shared/js/background/classes/site')
const utils = require('../../../shared/js/background/utils')
const browserWrapper = require('../../../shared/js/background/wrapper')

const contentScriptUtils = require('../../../shared/content-scope-scripts/src/utils.js')
const contentScriptUtils = require('@duckduckgo/content-scope-scripts/src/utils.js')

const testSets = require('@duckduckgo/privacy-reference-tests/privacy-configuration/tests.json')
const configs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tdsStorage = require('../../../shared/js/background/storage/tds')

const tabManager = require('../../../shared/js/background/tab-manager')
const browserWrapper = require('../../../shared/js/background/wrapper')
const jsReferrerProtection = require('../../../shared/content-scope-scripts/src/features/referrer')
const jsReferrerProtection = require('@duckduckgo/content-scope-scripts/src/features/referrer')

const limitReferrerData = require('../../../shared/js/background/events/referrer-trimming')

Expand Down

0 comments on commit 2cab7b5

Please sign in to comment.